fmw42 wrote:It is not your input image. It did not matter with JPG which does not support transparency. It is the delegate being used to write the PDF. IM uses Ghostscript for PDF. Not sure if just reading or both reading and writing. The delegates.xml file shows
So it might that one of these forces it to write the fully opaque alpha channel rather than no alpha channel.
Ahhhh, I see. that's very interesting. Thank you for clarifying (I would have never figured this out on my own).
fmw42 wrote:I do not know enough about either, but you might be able to use gs to write your output directly or modify the above line in your delegates.xml file to tell it not to write the alpha channel. Sorry, I just don't know enough in this area.
No worries at all! I really appreciate all of your help!
I actually did try to learn how to use GS to create a PDF, but unfortunately, from what I could tell, GS can't make a PDF from a globbed directory of image files. With that said, I will do some more investigating.
You can find the compression setting and if there is an alpha channel in the verbose information for your output, via
Interesting! I ended up running the above command on two PDFs.
ImageMagick-created (relevant info):
Code: Select all
Format: PDF (Portable Document Format)
Mime type: application/pdf
Class: DirectClass
Geometry: 621x630+0+0
Resolution: 72x72
Print size: 8.625x8.75
Units: Undefined
Type: TrueColorAlpha
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: 391230
Red:
min: 0 (0)
max: 65535 (1)
mean: 17971 (0.27422)
standard deviation: 23984.7 (0.365984)
kurtosis: -0.821928
skewness: 0.926717
entropy: 0.702296
Green:
min: 2570 (0.0392157)
max: 65535 (1)
mean: 31195.9 (0.476019)
standard deviation: 19404.1 (0.296088)
kurtosis: -1.2913
skewness: 0.55737
entropy: 0.936192
Blue:
min: 0 (0)
max: 65535 (1)
mean: 29607.2 (0.451777)
standard deviation: 19640.6 (0.299696)
kurtosis: -1.29059
skewness: 0.567892
entropy: 0.932274
Alpha:
min: 65535 (1)
max: 65535 (1)
mean: 65535 (1)
standard deviation: 0 (0)
kurtosis: 0
skewness: 0
entropy: 0
And here's a PDF where I used GS to optimize the ImageMagick-created PDF:
Code: Select all
Format: PDF (Portable Document Format)
Mime type: application/pdf
Class: DirectClass
Geometry: 621x630+0+0
Resolution: 72x72
Print size: 8.625x8.75
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: 391230
Red:
min: 0 (0)
max: 65535 (1)
mean: 50281.4 (0.767246)
standard deviation: 18430 (0.281224)
kurtosis: 0.456069
skewness: -1.40546
entropy: 0.838868
Green:
min: 0 (0)
max: 65535 (1)
mean: 50288.3 (0.76735)
standard deviation: 18432.3 (0.281259)
kurtosis: 0.456317
skewness: -1.40567
entropy: 0.83818
Blue:
min: 0 (0)
max: 65535 (1)
mean: 50280.7 (0.767234)
standard deviation: 18429.8 (0.281221)
kurtosis: 0.455978
skewness: -1.40539
entropy: 0.838893
Alpha:
min: 65535 (1)
max: 65535 (1)
mean: 65535 (1)
standard deviation: 0 (0)
kurtosis: 0
skewness: 0
entropy: 0
This is the GS command I am using to test:
Code: Select all
gs \
-dNOPAUSE \
-dBATCH \
-dQUIET \
-sDEVICE=pdfwrite \
-dAutoRotatePages=/None \
-dColorConversionStrategy=/LeaveColorUnchanged \
-dColorImageDownsampleType=/Bicubic \
-dColorImageResolution=304 \
-dCompatibilityLevel=1.4 \
-dDoThumbnails=true \
-dPreserveOverprintSettings=true \
-sOutputFile=${args.gsConvertedPdf} \
${args.imageMagickPdf}
Strange that they both say 72x72 for resolution? Also, I assume "Type: TrueColorAlpha" and "Type: PaletteAlpha" are the lines that would tell me if there's an alpha channel?
fmw42 wrote:Best quality in a PDF is really what density you use when converting to raster formats, but it may also depend upon the density you use to convert your raster into the PDF. The PDF is a vector format that does not have a quality or size per se. But in this case you are imbedding a raster image into a vector PDF shell. So both might matter.
Interesting! So, that might explain why the PDF info from above say 72x72 … That's the PDF resolution, but not the resolution of the images?
Excellent tips! Thank you so much for the clarification, linkages and help! I really owe you one (er, I owe you many)!
Thank you!