Re: Convert an image to a PDF
Re: Convert an image to a PDF
- Subject: Re: Convert an image to a PDF
- From: Roger Howard <email@hidden>
- Date: Fri, 27 May 2011 14:03:37 -0700
On May 27, 2011, at 1:28 PM, Leonid Bogdanov wrote:
> Hello!
>
> What is the best way of lossless conversion of an image (JPEG, PNG or BMP) to a PDF file from AppleScript?
> I tried to call sips, but it compresses an image being processed, so small images have poor quality in resulting PDFs.
> I tried to use cupsfilter, but it generates the resulting PDF in paper size (e.g. A4) and not of size equal to input image.
>
> I'll appreciate any suggestions of parameters for these tools to improve output or suggestions of another techniques.
I believe SIPS/ImageEvents does recompress images - quite sure of it. I tackled this issue last year for merging multiple JPEGs into a single PDF without re-compression and the best/easiest tool I found for the job was ImageMagick's convert tool (which, I believe, uses Ghostscript behind the scenes). I have an AppleScript wrapper that accepts folders (full of JPEGs) as input, and outputs each folder as a PDF. It's just calling ImageMagick's "convert" tool from do shell script.
Here's the simplest example of a convert command to do so:
convert *.jpg output.pdf
That will merge all files ending with .jpg in the current directory into a file named output.pdf.
If you wanted to include specific files in the input (instead of using a wildcard) it'd be similar:
convert /path/to/file1.jpg /path/to/file2.jpg /path/to/file3.jpg /path/to/output.pdf
This will work similarly with PNG's and BMP's as well (they'll both be stored without any lossy compression) - in fact you should be able to combine JPEG and PNG and BMP inputs in the same output PDF.
Not sure how comfy you are with command line tools and do shell script in general - if you need more info feel free to ask, or if you don't want to go this direction I understand. There is, I believe, a Mac installer for ImageMagic, and you can also get it through MacPorts ("port install ImageMagick" should do it).
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden