Bug 706294 - White logos on transparent background not rendered correctly
Summary: White logos on transparent background not rendered correctly
Status: RESOLVED INVALID
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PDF Interpreter (show other bugs)
Version: 9.54.0
Hardware: PC Windows 10
: P4 normal
Assignee: Default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-01-06 14:32 UTC by mirko_024
Modified: 2023-01-06 15:20 UTC (History)
0 users

See Also:
Customer:
Word Size: ---


Attachments
AI file (28.70 KB, application/postscript)
2023-01-06 14:32 UTC, mirko_024
Details
PDF file (90.57 KB, application/pdf)
2023-01-06 14:33 UTC, mirko_024
Details

Note You need to log in before you can comment on or make changes to this bug.
Description mirko_024 2023-01-06 14:32:47 UTC
Created attachment 23662 [details]
AI file

Using following commands:
gswin64c.exe -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -dPrinted=false  "-sOutputFile=out.png" 1.ai

gswin64c.exe -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -dPrinted=false  "-sOutputFile=out.png" 2.pdf

Expected is that PNG files produced contain white logos with transparent background. 

But instead PNG file in one case contains only white, and in second only transparent.

Can you please help me to send right parameters with which output will be correct?

Thanks in advance!

Kind regards,

Mirko
Comment 1 mirko_024 2023-01-06 14:33:18 UTC
Created attachment 23663 [details]
PDF file
Comment 2 Ken Sharp 2023-01-06 15:20:54 UTC
(In reply to mirko_024 from comment #0)

> Using following commands:
> gswin64c.exe -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT
> -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha"
> -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -dPrinted=false 
> "-sOutputFile=out.png" 1.ai

Ghostscript doesn't claim to be able to process Illustrator files. In this case the file is actually a PDF file with the Illustrator format contained within it (referenced from the Page dictionary as '/PieceInfo <</Illustrator 6 0 R>>'.

 
> gswin64c.exe -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT
> -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha"
> -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -dPrinted=false 
> "-sOutputFile=out.png" 2.pdf
> 
> Expected is that PNG files produced contain white logos with transparent
> background. 
> 
> But instead PNG file in one case contains only white, and in second only
> transparent.
> 
> Can you please help me to send right parameters with which output will be
> correct?

Well, no.

The problem here is I think your expectation,or at least what you think is in the files you have provided. If we start by looking at the content of the Illustrator file, and treat it as a PDF file (because Ghostscript will process it that way, ignoring the Illustrator format) we see:

4 0 obj
<<
/Type /Page
/Parent 2 0 R
/Contents 5 0 R
...

So object 5 contains the drawing operations for the page, looking at that we see:

5 0 obj
<<
  /Length 60
>>
stream
1.00000 0.00000 0.00000 1.00000 0.0000 0.0000 cm
/GS11 gs
endstream
endobj

So it draws nothing at all. That's why the output is completely transparent.


Now lets look at the second file, which claims to be a PDF file. In this case there is some interesting metadata in the Info dictionary:

  /Creator (Adobe Illustrator CS6 \(Windows\))
  /GTS_PDFXVersion (PDF/X-4)
  /ModDate (D:20221018124054+02'00')
  /Producer (Adobe Photoshop for Windows -- Image Conversion Plug-in)

So we can see that there has been some kind of image conversion done by Photoshop, even though the file was created by Illustrator. I note that the file was created 18/10/2022 at 12:39:40 and modified at 12:40:54. I don't know why the file was modified, but as we'll see that may be the problem.

So looking in the actual PDF we see:

6 0 obj
<<
  /ArtBox [ 0 0 290.160004 235.440002 ]
  /Contents 8 0 R
....
  /Resources <<
    /ColorSpace <<
      /DefaultRGB 7 0 R
    >>
    /ProcSet [ /PDF /ImageC ]
    /XObject <<
      /Im0 10 0 R
    >>
  >>
....


The content stream is :

8 0 obj
<<
  /Length 47
>>
stream
q
290.1600037 0 0 235.4400024 0 0 cm
/Im0 Do
Q
endstream
endobj

So that does nothing but draw an image (named /Im0). If we look at /Im0 (object 10) it is a simple image:

10 0 obj
<<
  /BitsPerComponent 8
  /ColorSpace /DeviceRGB
  /Type /XObject
  /Width 403
  /Height 327
  /ImageName /ps57A3.jpg
  /Intent /Perceptual
  /Length 395343
  /Name /ps57A3.jpg
  /Subtype /Image
>>
stream

Unless you are able to decompress the data yourself you'll just have to take my word for it that the image simply contains pure white image samples. So its a white rectangle. Which is exactly what the pngalpha device draws for this file.

I do wonder if the 'modification' involving Photoshop is what did the damage here.

Looking at the Illustrator format I do see that it is considerably more complex than what is in the PDF file, but Ghostscript only processes the PDF content of each file, and as far as I can see it is doing so 100% correctly.