Size problem when converting JPG's to PDF

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

I don’t have an answer but I have a guess at what the problem may be. My guess would be that there are differences in the dots-per-inch (dpi) of the jpg and pdf images. The size changes are happening because the dpi is being modified when going from one format to the other.

It’s only a guess but you may want to check on that.

you could probably do the conversion with Image Events instead of a shell script, which would let you control the resolution of images.

Also be aware that your removeExtension handler as currently written is going to munge filenames which contain more than one dot. You want to return everything except the last item, not just the first item.

Thanks for the replies. As it happens, I came across a free (donationware) piece of software called “Combine PDF’s 3.0” that does just the job I need, with no resolution problems. It’s available from http://www.monkeybreadsoftware.de/Freeware/CombinePDFs.shtml if anyones interested.