|
|
A script to convert screenshots to JPG format
PNG is a lossless format which realizes the best compression compared to GIF and TIFF and it supports more than 256 colors. Thanks to this hint we now have a way to quickly convert screen snapshots from PDF to PNG.
(Gives, "Warning: Output file format does not support saving some properties" but the resulting PNG looks fine to me.) Before, I would have to open each one with Preview, export as PNG, and change the popup from JPEG to PNG every single time because the app isn't smart enough to remember the last selected export format. Worse still is that Preview isn't even AppleScript-able. BAH. Thanks for this hint, I didn't even know that /usr/bin/sips existed!
#!/bin/sh
# This file: ~/bin/sipscon or pdf2png
# Set your preferred output format here.
# png tiff jpeg gif
format=png
# Don't touch anything below.
NOTENOUGHARGS=0
E_BADARGS=65
if [ $# = "$NOTENOUGHARGS" ]
then
me=`basename $0`
echo "Converts images to ${format} format via /usr/bin/sips."
echo "Usage: $me [input files]"
echo " $me *.pdf"
echo " $me Picture\ 1.pdf"
echo " $me \"Picture 1.tiff\" Picture\ 2.gif"
exit $E_BADARGS
fi
# Delimit with quotes to allow for filenames with spaces!
for filename in "$@"
do
echo "Converting ${filename} to ${format} format: \
${filename%.*}.${format}"
/usr/bin/sips -s format ${format} "${filename}" \
-o "${filename%.*}.${format}"
echo
done
echo "Done."
# Reference:
# http://www.tldp.org/LDP/abs/html/refcards.html#AEN15979
A script to convert screenshots to JPG format
For some reason, the \ character did not show up in the HTML of the above script.
A script to convert screenshots to JPG format
[baracus:~] gdanko% screencapture ./screen.pdf |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysNo new commentsLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.09 seconds |
|