Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>DNA decided to go for grayscale PNGs. The way he's creating them is in two steps:</p> <ol> <li><strong>Step 1:</strong> Convert a color PDF page (such as <a href="http://dl.dropbox.com/u/13223318/L_2lambda_max_1wl_E0_1_zg.pdf" rel="nofollow"><strong>this</strong></a>) to a grayscale PDF page, using Ghostscript's <code>pdfwrite</code> device and the settings<br> <code>-dColorConversionStrategy=/Gray</code> and<br> <code>-dProcessColorModel=/DeviceGray</code>.</li> <li><strong>Step 2:</strong> Convert the grayscale PDF page to a PNG, using Ghostscript's <code>pngalpha</code> device at a resolution of 300 dpi (<code>-r300</code> on the GS commandline).</li> </ol> <p>This reduces his initial file size of 1.4 MB to 0.7 MB.</p> <p>But this workflow has the following disadvantage:</p> <ul> <li><em>It looses all color info, without saving much disk space as compared to a <strong>color</strong> output written at the same resolution, directly from the PDF!</em></li> </ul> <p>There are 2 alternatives to DNA's workflow:</p> <ol> <li><p>A one-step conversion of (color) PDF -> (color) PNG, using Ghostscript's <code>pngalpha</code> device with the original PDF as input (same settings of 300 dpi resolution). This would have this advantage:</p> <ul> <li><em>It would keep the color information in the PNG output, requiring only a little more space on disk!</em> </li> </ul></li> <li><p>A one-step conversion of (color) PDF -> grayscale PNG, using Ghostscript's <code>pnggray</code> device with the original PDF as input (same settings of 300 dpi resolution), with this mix of advantage/disadvantage :</p> <ul> <li><em>It would loose the color information in the PNG output.</em></li> <li><em>It would loose the transparent background that was preserved in DNA's workflow.</em></li> <li><em>It would save <strong>lots</strong> of disk space, because the filesize would go down to about 20% of the output from DNA's workflow.</em></li> </ul></li> </ol> <p>So you can make up your mind and see the output sizes and quality side-by-side, here is a shell script to demonstrate the differences:</p> <pre> #!/bin/bash # # Copywrite (c) 2012 &lt;kurt.pfeifle@gmail.com&gt; # License: Creative Commons (CC BY-SA 3.0) function echo_do() { echo echo "Command: ${*}" echo "--------" echo "${@}" } [ -d out ] || mkdir out echo echo " We assume all PDF pages are 1-page PDFs!" echo " (otherwise we'd have to include something like '%03d'" echo " into the output filenames in order to get paged output)" echo echo ' # Convert Color PDF to Grayscale PDF. # If PDF has transparent background (most do), # this will remain transparent in output.) # ATTENTION: since we don't use a resolution, # pdfwrite will use its default value of '-r720'. # (However, this setting will only affect raster objects...) ' for i in *.pdf do echo_do gs \ -o "out/${i}---pdfwrite-devicegray-gs.pdf" \ -sDEVICE=pdfwrite \ -dColorConversionStrategy=/Gray \ -dProcessColorModel=/DeviceGray \ -dCompatibilityLevel=1.4 \ "${i}" done echo ' # Convert (previously generated) grayscale PDF to PNG using Alpha channel # (Alpha channel can make backgrounds transparent) ' for i in out/*pdfwrite-devicegray*.pdf do echo_do gs \ -o "out/$(basename "${i}")---pngalpha-from-pdfwrite-devicegray-gs.png" \ -sDEVICE=pngalpha \ -r300 \ "${i}" done echo ' # Convert (color) PDF to grayscale PNG using Alpha channel # (Alpha channel can make backgrounds transparent) ' for i in *.pdf do # Following only required for 'pdfwrite' output device, not for 'pngalpha'! # -dProcessColorModel=/DeviceGray echo_do gs \ -o "out/${i}---pngalphagray_gs.png" \ -sDEVICE=pngalpha \ -dColorConversionStrategy=/Gray \ -r300 \ "${i}" done echo ' # Convert (color) PDF to (color) PNG using Alpha channel # (Alpha channel can make backgrounds transparent) ' for i in *.pdf do echo_do gs \ -o "out/${i}---pngalphacolor_gs.png" \ -sDEVICE=pngalpha \ -r300 \ "${i}" done echo ' # Convert (color) PDF to grayscale PNG # (no Alpha channel here, therefor [mostly] white backgrounds) ' for i in *.pdf do echo_do gs \ -o "out/${i}---pnggray_gs.png" \ -sDEVICE=pnggray \ -r300 \ "${i}" done echo " All output to be found in ./out/ ..." echo </pre> <p>Run this script and compare the different outputs side by side.</p> <p>Yes, the 'direct-grayscale-PNG-from-color-PDF-using-pnggray-device' one may look a <em>bit</em> worse (and it doesn't sport the transparent background) than the other one -- but it is also only 20% of its file size. On the other hand, if you wan to buy a bit more quality by sacrificing a bit of disk space -- you could use <code>-r400</code> instead of <code>-r300</code>...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload