Opened 13 years ago
Closed 13 years ago
#20555 closed defect (bug) (fixed)
reserve PNG Format and Transparency for Flexible-Height and Flexible-Width Custom Headers
Reported by: | chellycat | Owned by: | ryan |
---|---|---|---|
Milestone: | 3.4 | Priority: | high |
Severity: | normal | Version: | 3.4 |
Component: | Customize | Keywords: | has-patch |
Focuses: | Cc: |
Description
Normally, when a user uploads a custom header image, they are prompted to crop the image to their desired size if the image is not the exact dimensions specified by the theme. After cropping, the image is compressed and becomes a JPG.
In the past, if users wanted to avoid this compression (to use a transparent PNG for their header image, for example), they could upload their header image at the exact dimensions specified by the theme.
However, with the flexible dimensions, users are always prompted to crop. This means that transparent pngs are converted to JPG and lose their transparency in the process.
To replicate:
- Switch to a theme that supports flexible header dimensions (such as Twenty Eleven)
- Go to Appearance > Header and upload a transparent png that has the "recommended dimensions" specified by the theme.
- You'll be prompted to crop the image.
- After cropping, observe how the image becomes a JPG and thus loses its transparency.
The ideal solution would be for PNG images to remain PNGs and to preserve their transparency when cropped.
Attachments (3)
Change History (12)
#2
@
13 years ago
- Keywords has-patch added
We could preserve PNG transparency in wp_crop_image()
in the same way image_resize()
does.
#4
@
13 years ago
- Cc kovshenin@… added
@SergeyBiryukov your patch works great against latest trunk. Let's also read the image type before creating an attachment post when cropping a header image, otherwise WP thinks it's a jpeg which then breaks Edit Image.
#5
follow-up:
↓ 7
@
13 years ago
- Priority changed from normal to high
I agree with preserving transparency.
Additionally, if $src_x = $src_y = 0, and $src_w = $dst_w, and $src_h = $dst_h, can't we just avoid the crop all together?
#7
in reply to:
↑ 5
@
13 years ago
Replying to nacin:
Additionally, if $src_x = $src_y = 0, and $src_w = $dst_w, and $src_h = $dst_h, can't we just avoid the crop all together?
Done in 20555.3.patch.
#8
@
13 years ago
20555.3.patch is working well for me and appears to play nicely with file replication on wordpress.com.
If I crop an image to the default crop and upload that image as a new header, it is nigh impossible to get the the exact some crop dimensions again. I could get it to within 1 pixel for x or y. So, I couldn't avoid a crop, but at least it retained png.
This is pretty lame. Let's see if there's a way to allow someone to use the original as uploaded (perhaps if there is no crop).