Skip to content

Instantly share code, notes, and snippets.

@hugooliveirad
Last active February 24, 2021 00:29
Show Gist options
  • Save hugooliveirad/7628357 to your computer and use it in GitHub Desktop.
Save hugooliveirad/7628357 to your computer and use it in GitHub Desktop.
Convert RAW images (.NEF) to jpeg and create shareble versions
#!/bin/bash
# create folders. Ensure your directory is writable
mkdir -p jpegs/share;
# loops .NEF files in this directory. Subdirectories aren't supported
for f in *.NEF;
do
# gets filename and inserts .jpg at the end
jpg=`basename $f`; jpg="${jpg%.*}.jpg";
# converts to jpeg with 90% quality
sips -s format jpeg -s formatOptions 90 "$f" -o "jpegs/$jpg";
# converts the output jpeg resizing to 1600px retaining aspect-ratio
# (width or height, what fits first) and saves to 'share' folder
sips -Z 1600 "jpegs/$jpg" -o "jpegs/share/$jpg"
done;
@JKCowboy
Copy link

Thanks!

@harsham05
Copy link

Thank you!

@johnlonganecker
Copy link

Thanks for sharing this, for some reason I had to change -o to --out on the sips commands.

sips -s format jpeg -s formatOptions 90 "$f" --out "jpegs/$jpg";
sips -Z 1600 "jpegs/$jpg" --out "jpegs/share/$jpg"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment