Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'A script to convert screenshots to JPG format' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A script to convert screenshots to JPG format
Authored by: prodok on Apr 07, '04 12:52:16PM

Nothing against the script, but I would be very cautious to convert screenshots to JPEG format. Screenshots are normally relatively low on the number of colors, and contain bigger areas of the same color, as well as high local contrasts. The JPEG format on the other hand has been developed for photographic images with many different colors and small areas of the same color and low local contrasts.

An image containing high contrasts and even colored areas will produce very ugly artefacts when converted to JPEG. And this may not really be what was wanted. It is normally more recommended to use a lossless file format, and then reduce the number of colors so that indexed colors can be used. A good example for such a format would be GIF, but TIFFs can be used in a same way.



[ Reply to This | # ]
A script to convert screenshots to JPG format
Authored by: carsten on Sep 28, '04 09:01:21PM

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.

/usr/bin/sips -s format png Picture\ 1.pdf -o Picture\ 1.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


[ Reply to This | # ]
A script to convert screenshots to JPG format
Authored by: carsten on Sep 28, '04 09:06:29PM

For some reason, the \ character did not show up in the HTML of the above script.

Line 18 should read:
echo " $me \"Picture 1.tiff\" Picture\ 2.gif"

Line 25 should read:
echo "Converting ${filename} to ${format} format: \

Line 27 should read:
/usr/bin/sips -s format ${format} "${filename}" \

Sorry for the confusion.



[ Reply to This | # ]
A script to convert screenshots to JPG format
Authored by: gdanko on Oct 18, '04 06:41:54PM

[baracus:~] gdanko% screencapture ./screen.pdf
[baracus:~] gdanko% sips -s format png screen.pdf -o screen.png
/Volumes/Vandelay/Users/gdanko/screen.pdf
Error: An error -50 occured
/Volumes/Vandelay/Users/gdanko/screen.png



[ Reply to This | # ]