I often use Imagemagick for image manipulation1. However, for simple conversion of an image to another format or similar things I have to go to the terminal and type something like the following
convert somefile.png somefile.pdf
Which is quite simple, and much better than opening preview -> export2->select pdf-> and hit save. But typing that for more than one image is also tedious. So, I decided I’d better create a service that would essentially do the following.
It would take the selected finder items, mainly images in png
, jpeg
, or whatever, and convert all of them to pdf
. Simple. The automator service is shown in the following image. It does exactly what I’ve described.
The shell script is quite simple. Because the convert
command from Imagemagick is not a command in bash, I have to call it with the whole path. The rest of that one-liner is a sed
call to substitute whatever extension the input file has (with the regex \..*
) to .pdf
, and that’s it. Here’s the script.
1 2 3 4 5 |
|