#2805 closed defect (bug) (fixed)
Preserve PNG transparency/alpha during thumbnail creation
| Reported by: | Libertus | Owned by: | westi |
|---|---|---|---|
| Priority: | high | Milestone: | 2.5 |
| Component: | Administration | Version: | 3.0.4 |
| Severity: | major | Keywords: | |
| Cc: | Focuses: |
Description
PNG images with transparent backgrounds get thumbnails with black backgrounds. This patch to wp_create_thumbmail() fixes that.
Attachments (4)
Change History (17)
#2
@
19 years ago
- Resolution → wontfix
- Status new → closed
No traction in almost a year, so closing as wontfix.
Feel free to re-open it if you have additional information/suggestions/patches/...
#3
@
19 years ago
- Resolution wontfix
- Status closed → reopened
I really wish this will be fixed!! This is really sad that WP lost the transparency in the PNG... Why can't it be integrated into WP main code?
I have to do and redo the modification at each update!! :-(
After the line 2294 of this file: http://trac.wordpress.org/browser/tags/2.2.1/wp-admin/admin-functions.php
add the following lines:
if ( ( $type[2] == 3) AND ( function_exists( 'imagesavealpha' ) ) ) {
imagesavealpha( $thumbnail, TRUE );
$trans_colour = imagecolorallocatealpha($thumbnail, 0, 0, 0, 127);
imagefill($thumbnail, 0, 0, $trans_colour);
}
This code was taken from this documentation page: http://fr.php.net/manual/en/function.imagecreatetruecolor.php
#5
@
19 years ago
- Milestone 2.4 (future) → 2.3 (trunk)
Uploaded a simpler patch which should do the trick for trunk. Somebody test it out.
This does need to be in trunk, IMO. Uploading transparent PNG files only to have it mangle their thumbnails is a pretty bad user experience. This is a simple patch that just sets some flags in the GD functions if those flags are available.
#6
@
19 years ago
- Keywords has-patch needs-testing added
- Severity normal → major
While I agree I would like to see this in 2.3.
It needs some testing before it can go in.
#8
@
19 years ago
If anybody else wants to test, a bunch of transparent png's to test with can be found here:
http://entropymine.com/jason/testbed/pngtrans/
#11
in reply to: ↑ description
@
16 years ago
- Keywords has-patch needs-testing removed
- Resolution fixed
- Status closed → reopened
- Version 2.1 → 3.0.4
The solution doesn't work for 8 bit PNGs. I attached the two files I encountered the problem with, in a ZIP.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
the patch