Make WordPress Core

Opened 9 years ago

Closed 8 years ago

Last modified 8 years ago

#30596 closed defect (bug) (fixed)

Transparent background of .png not preserved when rotating picture

Reported by: frankpw's profile frankpw Owned by: markoheijnen's profile markoheijnen
Milestone: 4.2 Priority: normal
Severity: normal Version: 3.5
Component: Media Keywords: needs-patch
Focuses: Cc:

Description

Rotating .png picture with transparent background does not preserve transparency. Resulting picture has partially black background.

Attachments (3)

class-wp-image-editor-gd.php.patch (726 bytes) - added by frankpw 9 years ago.
class-wp-image-editor-gd.php.2.patch (730 bytes) - added by frankpw 9 years ago.
Formatting correction to previous patch
30596.diff (2.9 KB) - added by voldemortensen 9 years ago.

Download all attachments as: .zip

Change History (23)

#1 @frankpw
9 years ago

  • Keywords has-patch added
  • Severity changed from normal to major

@frankpw
9 years ago

Formatting correction to previous patch

#2 @boonebgorges
9 years ago

  • Severity changed from major to normal
  • Version changed from trunk to 3.5

Looks like this code has not been touched since at least 3.5. Is the same happening with Imagick?

#3 @frankpw
9 years ago

I had no chance to test Imagic as GD seems to be more popular and all my servers have GD installed ( but no Imagic ).

#4 @voldemortensen
9 years ago

I've been doing some testing and it doesn't seem like Imagick is doing it wrong. Created a new instance of WP_Image_Editor_Imagick, rotated it 180˚, saved it, and printed it out in an img. Visually the transparency is the same. Also created new Imagick instances to be able to check the image alpha itself. Long story short the alpha didn't change using Imagick.

#5 @frankpw
9 years ago

As I said I did not check Imagic. My patch fixes transparency problem in GD.

#6 @voldemortensen
9 years ago

I was responding to boonebgorges's question since he asked if it did happen with Imagick. I did the testing and reported my findings.

#7 @boonebgorges
9 years ago

  • Keywords 4.2-early added
  • Milestone changed from Awaiting Review to Future Release

Thanks to both for your feedback. The patch looks fine at a glance. voldemortensen - since you were recently looking at the image unit tests, maybe you can dream up a way to write a test for this?

#8 @voldemortensen
9 years ago

That one's going to be a nightmare. I will work on them.

@voldemortensen
9 years ago

#9 @voldemortensen
9 years ago

Turns out it wasn't as hard as I thought it would be. Just had to use my brain. Patch includes the fix and unit tests for both Imagick and GD keeping alpha on rotate.

#10 @wonderboymusic
9 years ago

  • Milestone changed from Future Release to 4.2

#11 @wonderboymusic
9 years ago

  • Owner set to wonderboymusic
  • Resolution set to fixed
  • Status changed from new to closed

In 31040:

Preserve alpha transparency when rotating a PNG while GD is the active image editor.

Adds unit tests.

Props frankpw, voldemortensen.
Fixes #30596.

#12 @markoheijnen
9 years ago

  • Keywords has-patch removed
  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening after seeing inconsistency in the usage of imagealphablending. I believe the one in load also should be true.
We could also move the lines into a separate protected method so others could use it too when extended the class. I do wonder if the function_exists is needed. It's there because of wp_imagecreatetruecolor which is from #6005 so quite old.

#13 @wonderboymusic
9 years ago

  • Owner changed from wonderboymusic to markoheijnen
  • Status changed from reopened to assigned

#14 @iseulde
9 years ago

  • Keywords needs-patch added

#15 @DrewAPicture
9 years ago

@markoheijnen: Can you please follow up here on whether there's still a problem following [31040]? If there is, we're running out of time to fix this in 4.2.

#16 @DrewAPicture
9 years ago

  • Milestone changed from 4.2 to Future Release

No meaningful activity in several months, and it seems like we need a new patch. Let's pick this up in a future release. Sorry folks.

#17 @obenland
9 years ago

  • Keywords 4.2-early removed
  • Milestone changed from Future Release to 4.3

This ticket was mentioned in Slack in #core by helen. View the logs.


8 years ago

#19 @helen
8 years ago

  • Milestone changed from 4.3 to 4.2
  • Resolution set to fixed
  • Status changed from assigned to closed

This was fixed in 4.2. If enhancements are desired for the fix, let's open a new ticket for that.

#20 @mikeschroder
8 years ago

In 36998:

Media: Fix typo in test_image_preserves_alpha_on_rotate().

peserves -> preserves; introduced in [31040].

See #30596.

Note: See TracTickets for help on using tickets.