Make WordPress Core

Opened 12 years ago

Closed 11 years ago

Last modified 10 years ago

#30596 closed defect (bug) (fixed)

Transparent background of .png not preserved when rotating picture

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

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 12 years ago.
class-wp-image-editor-gd.php.2.patch (730 bytes ) - added by frankpw 12 years ago.
Formatting correction to previous patch
30596.diff (2.9 KB ) - added by voldemortensen 12 years ago.

Download all attachments as: .zip

Change History (23)

#1 @frankpw
12 years ago

  • Keywords has-patch added
  • Severity normalmajor

@frankpw
12 years ago

Formatting correction to previous patch

#2 @boonebgorges
12 years ago

  • Severity majornormal
  • Version trunk3.5

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

#3 @frankpw
12 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
12 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
12 years ago

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

#6 @voldemortensen
12 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
12 years ago

  • Keywords 4.2-early added
  • Milestone Awaiting ReviewFuture 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
12 years ago

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

#9 @voldemortensen
12 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
12 years ago

  • Milestone Future Release4.2

#11 @wonderboymusic
12 years ago

  • Owner set to wonderboymusic
  • Resolutionfixed
  • Status newclosed

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
12 years ago

  • Keywords has-patch removed
  • Resolution fixed
  • Status closedreopened

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
12 years ago

  • Owner changed from wonderboymusic to markoheijnen
  • Status reopenedassigned

#14 @iseulde
12 years ago

  • Keywords needs-patch added

#15 @DrewAPicture
11 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
11 years ago

  • Milestone 4.2Future 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
11 years ago

  • Keywords 4.2-early removed
  • Milestone Future Release4.3

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


11 years ago

#19 @helen
11 years ago

  • Milestone 4.34.2
  • Resolutionfixed
  • Status assignedclosed

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

#20 @kirasong
10 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.