How to convert PDF to image by command line on Mac?

Question: Attempting to compress tiffs during the conversion from PDF to image with LZW compression. However,there is no difference in file size at all with using compression VS not using compression. Any thoughts?

*****************************************************************

Solution: In order to help those who have the need to convert PDF to image by command line under Mac, here I will make a brief introduction of software VeryPDF PDF to Image Converter Command Line for Mac. As its name implies, this software can be used to convert PDF files to various image formats, such as TIF, TIFF, BMP, PNG, EMF, GIF, JPG, JPEG, PCX, and TGA. It can also convert a whole PDF page to an image file including text, line, color, arc, ellipse, image, Bezier, form, etc.

As to why the compression does not work,  as far as I know, this kind of situation happens on a few PDF files but not always. If the output file size is very small, it can not be compressed, so there will not have any big difference whether you add LZW or not.  If you input the right command line, there should have problem. The following are some examples for your reference.

   ./pdf2img -compress 5 -mono C:\in.pdf C:\out.tif
   ./pdf2img -compress 5 -mono -multipage C:\in.pdf C:\out.tif
-compress 5  is the parameter for compress output file by LZW compression method.

If you ask that “If the compression method is useless, can I reduce its size by lowering its color bit count?” The answer is “absolute yes”. There is one parameter like “-dither”   which enables or disables dithering when reduce the number of bits per pixel to bit (1, 4 or 8). The defaults bit depth is 8.
Example:
./pdf2img -dither 1 -mono C:\in.pdf C:\out.tif
./pdf2img -dither 0 -mono C:\in.pdf C:\out.tif

And there are also many other compression methods provided by this software like the followings, you can use one of them during the conversion from PDF to image.
   -compress <int>     : set compression to TIFF format:
   -compress 1     : NONE compression
   -compress 2     : CCITT modified Huffman RLE
   -compress 3     : CCITT Group 3 fax encoding (1d)
   -compress 4     : CCITT Group 4 fax encoding
   -compress 5     : LZW compression
   -compress 6     : OJPEG compression
   -compress 7     : JPEG DCT compression
   -compress 8     : ADOBE_DEFLATE compression
   -compress 32773 : PACKBITS compression
   -compress 32809 : THUNDERSCAN compression
   -compress 32946 : DEFLATE compression
   -compress 88880 : 204x98  G4 ClassF TIFF
   -compress 88881 : 204x196 G4 ClassF TIFF
   -compress 88882 : 204x98  G3 ClassF TIFF
   -compress 88883 : 204x196 G3 ClassF TIFF
   -compress 88884 : CCITT Group 3 fax encoding (2d)

Now let us check the conversion effect from the following snapshots. Fig. 1. is from the input PDF file. Its size is 4.89MB.

input PDF file
        Fig. 1. input PDF file

Now let us check the output image file, tif for example.

output image tif file
     Fig.2. output image tif file

This is the case what the question shows that even if I use the compression method LZW, but the output image file size is larger than the input PDF file. The reason for this question is that the PDF file used more advanced compression method that LZW. During the conversion, the compression functions have been damaged. Then it is compressed by LZW, so its size will become larger. 

VN:F [1.9.20_1166]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.20_1166]
Rating: 0 (from 0 votes)

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *


Verify Code   If you cannot see the CheckCode image,please refresh the page again!