I'm new Apple Automator scripting, I create a new Document type (Quick Action) named, reduceTo700
I have it Run Shell Script
for f in "$@"
do
/usr/bin/sips -Z 700 "$f" --out "${f%.*}.700px.jpg"
/usr/bin/pbcopy < "${f%.*}.700px.jpg"
done
The logs show green, but I see no file generated.
How can I get this to work ?
Assuming the following:
you can use this:
# Pick up and use just first filename received
f="$1"
# Make temp file to ensure PNG and to ensure we can remove at end
tmp="$(/usr/bin/mktemp /tmp/sipsZ700-XXXXXX).png"
# Resize
/usr/bin/sips -Z 700 "$f" -s format png --out "$tmp"
# Tell Finder to put it on pasteboard
osascript <<EOF
tell app "Finder" to set the clipboard to (read ( POSIX file "$tmp" ) as {«class PNGf»})
EOF
# Clean up
rm "$tmp"
I hard-coded PNG format because it can support 8/16-bit images and also transparency, so it is arguably more flexible than JPEG.