[wp-trac] [WordPress Trac] #39216: PDFs with non-opaque alpha channels can result in previews with black backgrounds.

WordPress Trac noreply at wordpress.org
Thu Jan 10 14:59:59 UTC 2019


#39216: PDFs with non-opaque alpha channels can result in previews with black
backgrounds.
-------------------------------------------------+-------------------------
 Reporter:  gitlost                              |       Owner:  (none)
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  Awaiting
                                                 |  Review
Component:  Media                                |     Version:  4.7
 Severity:  normal                               |  Resolution:
 Keywords:  dev-feedback 2nd-opinion has-patch   |     Focuses:
  has-unit-tests                                 |
-------------------------------------------------+-------------------------

Comment (by mwtsn):

 Hi all,

 I've been faced with the black PDF thumbnail image issue, and I've come up
 with a solution. Mine is specific to Imagick.

 In the file `wp-includes/class-wp-image-editor-imagick.php` after line 153
 (`$this->image->readImage( $filename );`) you can put in the code:

 {{{
 $this->image->setImageBackgroundColor('white');
 $this->image = $this->image->flattenImages();
 }}}

 This fixes my issue. So I was wondering if it would be useful for us to
 add an action into the code at this point, so developers can easily add
 code into the solution to alter the image output as they need?

 Let me know if you think this approach is workable, and I will submit a
 patch.

 If not, I'll create a new version of `WP_Image_Editor_Imagick` and use the
 `'wp_image_editors'` filter to pull this in.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/39216#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list