[wp-trac] [WordPress Trac] #39216: PDFs with non-opaque alpha channels can result in previews with black backgrounds.
WordPress Trac
noreply at wordpress.org
Fri Dec 16 13:04:48 UTC 2016
#39216: PDFs with non-opaque alpha channels can result in previews with black
backgrounds.
--------------------------+------------------------------
Reporter: gitlost | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Media | Version: 4.7
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Comment (by gitlost):
There's also an issue with PDFs with CMYK color spaces, as the resulting
"full" jpegs will also have CMYK color spaces, and it turns out that
`Imagick::unsharpMaskImage()` (as called in
`WP_Image_Editor_Imagick::thumbnail_image()`) messes them up. In
particular black text becomes fuzzy and over-black, and colors change.
This can be seen using the attached "test_cmyk.pdf", generated using
TCPDF:
{{{
#!php
<?php
$dirname = dirname( __FILE__ );
$tcpdf_dirname = $dirname . '/tcpdf';
require $tcpdf_dirname . '/tcpdf.php';
$pdf = new TCPDF();
$pdf->AddSpotColor( 'spot_black', 0, 0, 0, 100 );
$pdf->AddSpotColor( 'spot_dark_blue', 89, 42, 0, 48 );
$pdf->AddPage();
$pdf->SetFontSize( 30 );
$pdf->SetTextSpotColor( 'spot_black' );
$pdf->Text( 20, 20, 'Spot Black' );
$pdf->SetFillSpotColor( 'spot_dark_blue' );
$pdf->Rect( 20, 40, 30, 30, 'DF' );
$pdf->SetFontSize( 18 );
$pdf->SetTextSpotColor( 'spot_dark_blue' );
$pdf->Text( 20, 70, 'Dark Blue' );
$pdf->Output( $dirname . '/test_cmyk.pdf', 'F' );
}}}
Not calling `Imagick::unsharpMaskImage()` if the color space is CMYK fixes
the fuzzy black text and severe color change issues, but still results in
noticeable color change. This could be ameliorated by adding ICC profiles
in the proposed `pdf_process()` method, but it's messy, and anyway I now
think that a much better solution to all these issues is to use
GhostScript directly - see #39262.
FWIW the following is a refreshed patch not calling
`Imagick::unsharpMaskImage()` if the color space is CMYK. The unit test
requires "test_cmyk.pdf" to be uploaded to the test data images directory.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39216#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list