I have an AppleScript that will convert a bunch of JPG’s to PDF format, then uses Automator to join them. However, the resulting images in the PDF are very small in size, compared to the original .JPG’s. I suspect this is a problem with the CUPSfilter that is called in the shell script, but it also happens in Preview if you add an image to an existing .PDF (opening an individual JPG in a new preview and saving as .PDF retains the correct size. It’s only a problem if you add a .JPG to an existing .PDF). Has anyone else seen this problem, and if so how can I code around it?
on run {input, parameters}
set selected_pdfs to {}
tell application “Finder” to set the selected_pics to input
repeat with i from 1 to the count of selected_pics
set picitem to (item i of selected_pics) as alias
set in_pic to POSIX path of picitem
set outpic to POSIX file in_pic
try
set text item delimiters to “:”
set file_name to last text item of (alias outpic as text)
set text item delimiters to “”
on error
set text item delimiters to “”
end try
set outpic to “/private/tmp/” & file_name
set outpic to (removeExtension(outpic)) & “.pdf”
do shell script "/System/Library/Printers/Libraries/./convert" & " -f " & quoted form of in_pic & " -o " & quoted form of outpic
set outpic_name to alias (POSIX file outpic)
set selected_pdfs to selected_pdfs & outpic_name
end repeat
return selected_pdfs
end run
– remove extension
on removeExtension(in_pic)
set outpic to {}
set AppleScript’s text item delimiters to “.”
return first text item of in_pic
end removeExtension