Page 1 of 1

Write to pdf does not respect depth or alpha off IM 6.9.7.5 Q16 Mac OSX

Posted: 2017-01-25T17:41:11-07:00
by fmw42
.
When I take an opaque image with no alpha channel and convert to pdf format, the result contains an opaque alpha channel and insists on being 16 bit, even though I add -depth 8 -alpha off. Using GS 9.16

Is this a limitation of Ghostscript or Imagemagick?

For example:

Logo:

Code: Select all

Image: LOGO
  Base filename: 
  Format: GIF (CompuServe graphics interchange format)
  Mime type: image/gif
  Class: PseudoClass
  Geometry: 640x480+0+0
  Units: Undefined
  Type: Palette
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
  Channel statistics:
    Pixels: 307200
    Red:
      min: 4 (0.0156863)
      max: 255 (1)
      mean: 229.323 (0.899307)
      standard deviation: 69.3423 (0.271931)
      kurtosis: 4.45973
      skewness: -2.49768
      entropy: 0.186315
    Green:
      min: 0 (0)
      max: 255 (1)
      mean: 226.217 (0.887127)
      standard deviation: 70.8689 (0.277917)
      kurtosis: 3.37246
      skewness: -2.24758
      entropy: 0.203574
    Blue:
      min: 0 (0)
      max: 255 (1)
      mean: 229.064 (0.898288)
      standard deviation: 64.1018 (0.251379)
      kurtosis: 4.65272
      skewness: -2.42185
      entropy: 0.206184
convert logo: -alpha off -depth 8 logo.pdf

Code: Select all

Image: logo.pdf
  Format: PDF (Portable Document Format)
  Mime type: application/pdf
  Class: DirectClass
  Geometry: 640x480+0+0
  Resolution: 72x72
  Print size: 8.88889x6.66667
  Units: Undefined
  Type: PaletteAlpha
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 16/8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
    alpha: 1-bit
  Channel statistics:
    Pixels: 307200
    Red:
      min: 1028 (0.0156863)
      max: 65535 (1)
      mean: 58936.1 (0.899307)
      standard deviation: 17821 (0.271931)
      kurtosis: 4.45973
      skewness: -2.49768
      entropy: 0.186315
    Green:
      min: 0 (0)
      max: 65535 (1)
      mean: 58137.8 (0.887127)
      standard deviation: 18213.3 (0.277917)
      kurtosis: 3.37246
      skewness: -2.24758
      entropy: 0.203574
    Blue:
      min: 0 (0)
      max: 65535 (1)
      mean: 58869.3 (0.898288)
      standard deviation: 16474.2 (0.251379)
      kurtosis: 4.65272
      skewness: -2.42185
      entropy: 0.206184
    Alpha:
      min: 65535 (1)
      max: 65535 (1)
      mean: 65535 (1)
      standard deviation: 0 (0)
      kurtosis: 0
      skewness: 0
      entropy: 0

Re: Write to pdf does not respect depth or alpha off IM 6.9.7.5 Q16 Mac OSX

Posted: 2017-01-26T05:08:28-07:00
by magick
Edit delegates.xml and change the ps:alpha device from pngalpha to pnmraw. That eliminates the alpha channel, not sure about the image depth. You could also use this command line: convert logo.pdf -alpha off -depth 8 logo.pdf logo.png.

Re: Write to pdf does not respect depth or alpha off IM 6.9.7.5 Q16 Mac OSX

Posted: 2017-01-26T10:05:03-07:00
by fmw42
You could also use this command line:

convert logo.pdf -alpha off -depth 8 logo.pdf logo.png.
Did you really mean two output images (pdf and png)?

I am not sure I understand this command. Why would I reprocess my output image (logo.pdf)?

I can get rid of the alpha channel using pnmraw. Thanks.

But I still get 16 bit results rather than 8 bits, even if I do

Code: Select all

convert logo.pdf -depth 8 logo.pdf
or

Code: Select all

convert logo: -alpha off -depth 8 PNG:- | convert - logo.pdf

Re: Write to pdf does not respect depth or alpha off IM 6.9.7.5 Q16 Mac OSX

Posted: 2017-01-26T18:41:01-07:00
by magick
The depth of the image is defined by the Ghostscript device you utilize to read the PDF. You can use whatever device you want, type 'gs -h' and it lists all the devices your instance of Ghostscript supports.

Re: Write to pdf does not respect depth or alpha off IM 6.9.7.5 Q16 Mac OSX

Posted: 2017-01-26T20:01:57-07:00
by fmw42
Thanks. I will look into that. Are all the devices listed by gs available for use with IM?

Is the same sDEVIDE used for reading and writing PDF? If so, I have a problem, since my client wants to read a PDF with transparency and then flatten it on white and write it out without transparency. That was the issue with using pngalpha that you pointed out. So if I change the sDEVICE from pnmraw to pngalpha, will I still be able to read a transparent PDF. I have verified that with pnmraw, it writes one without an opaque alpha channel correctly.

Re: Write to pdf does not respect depth or alpha off IM 6.9.7.5 Q16 Mac OSX

Posted: 2017-01-27T05:30:38-07:00
by magick
If you need transparency, you need the pngalpha device.

Re: Write to pdf does not respect depth or alpha off IM 6.9.7.5 Q16 Mac OSX

Posted: 2017-01-27T10:04:56-07:00
by fmw42
Thanks