On May 27, 2011, at 1:28 PM, Leonid Bogdanov wrote:
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.
Here's a script that I use; I don't know whether it compresses the image or not. So far as I know, all PDFs are saved at a paper size.
set theImage to choose file with prompt "Choose the file you wish to convert." of type "public.png" without invisibles
tell application "Finder"
set the file_path to the container of theImage as alias as string
set the Ext_hidden to the extension hidden of theImage
set the extension hidden of theImage to true
set the destination to (the container of theImage as alias as string) & the displayed name of theImage & ".pdf"
set the extension hidden of theImage to Ext_hidden
end tell
tell application "Image Events"
launch
set the ImageRef to open theImage
save the ImageRef in destination as PDF
close theImage
end tell