A script to convert screenshots to JPG format

Apr 07, '04 09:22:00AM

Contributed by: Accura

I was asked for a string of commands to take a desktop picture (in PDF format) and convert it to a JPG, so here's the script:

#!/bin/sh
/usr/sbin/screencapture theimage.pdf;
/usr/bin/sips -s format jpeg theimage.pdf -o theimage.jpg;
/bin/rm theimage.pdf;
The first line (after the #!/bin/sh declaration) takes a screen shot named theimage.pdf; the second line converts it to a JPG and saves it as theimage.jpg; and the third line removes the original PDF (theimage.pdf).

Make the script executable by typing:
chmod +x /path/to/saved/script
and run it with:
/path/to/script
[robg adds: If you want a generic script to handle converting any PDF to a JPEG, probably the best bet is to use the built-in Folder Action Script that converts images to JPGs -- with a couple minor edits, as described in this hint. Just take a screenshot and drag and drop it into the folder to which you've attached the script, and you're done ... quite useful!]

Comments (11)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20040402201110611