Menu

PS into PDF with fax group 4 encoding: unexpected result

Help
akapuma
2014-05-14
2014-05-14
  • akapuma

    akapuma - 2014-05-14

    Hello,

    I'm trying to convert some PS files into PDF with fax group 4 encoding (monochrome with very good compression). I'm using the following command line:

    gm convert -colors 2 -monochrome -compress group4 -density 300x300 -page A4 +dither in.ps out.pdf

    (Remark: without "-colors 2", "green" becomes "white". Tested with IM).

    Formerly, I used ImageMagick. The result is good, but it's very slow. Then, I tried GraphicsMagick. It's much faster, but the result is not OK:

    the "+dither" - command is ignored
    the pictue is not centered

    For testing, I used the file "testpage.ps" from this site: http://anders.geekhouse.no/Testpage/

    Can somebody help me?

    Best regards

    akapuma

     

    Last edit: akapuma 2014-05-14
    • Bob Friesenhahn

      Bob Friesenhahn - 2014-05-14

      On Wed, 14 May 2014, akapuma wrote:

      Hello,

      I'm trying to covert some PS files into PDF with fax group 4 encoding (monochrome with very good compression).
      I'm using the following command line:

      gm convert -colors 2 -monochrome -compress group4 -density 300x300 -page A4 +dither in.ps out.pdf

      (Remark: without "-colors 2", "green" becomes "white". Tested with IM).

      Formerly, I used ImageMagick. The result is good, but it's very slow. Then, I tried GraphicsMagick. It's much
      faster, but the result is not OK:

      • the "+dither" - command is ignored
      • the pictue is not centered

      For Testing, I used the file "testpage.ps" from this site: http://anders.geekhouse.no/Testpage/

      I am not sure about the centering but I achieve much better results by
      arranging the arguments in a more suitable order so they are actually
      used:

      gm convert -density 300x300 in.ps +dither -colors 2 -monochrome
         -compress group4 -page A4 out.pdf
      

      The reasining behind the reordering is

      -density 300x300 is needed by Ghostscript to render in.ps at correct
      resolution.

      +dither influences -colors 2

      If you don't mind doing the critital steps in Ghostscript, then this
      will obtain vastly better throughput since Ghostscript will then
      produce bilevel output directly:

      gm convert -type bilevel -density 300x300 in.ps -compress group4
          -page A4 out.pdf
      

      or perhaps this with Ghostscript producing Grayscale output rather
      than RGB:

      gm convert -type grayscale -density 300x300 in.ps +dither -colors 2
          -compress group4 -page A4 out.pdf
      

      I see a lot of aliasing problems in the output due to using +dither.

      Smoother output can be obtained by rendering at twice the density
      needed and then resizing the image by 50%. Using +dither only seems
      to cause harm to the output.

      gm convert -type grayscale -density 600x600 in.ps -resample 300x300
          -colors 2 -compress group4 -page A4 out.pdf
      
      gm convert -type grayscale -density 600x600 in.ps -resample 300x300
          -type bilevel -compress group4 -page A4 out .pdf
      

      Bob

      Bob Friesenhahn
      bfriesen@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
      GraphicsMagick Maintainer, http://www.GraphicsMagick.org/

       

Log in to post a comment.