Skip to content

Instantly share code, notes, and snippets.

@drewlustro
Created December 1, 2015 07:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drewlustro/03f228415e6886045f6d to your computer and use it in GitHub Desktop.
Save drewlustro/03f228415e6886045f6d to your computer and use it in GitHub Desktop.
#!/bin/bash
# requires hombrew
# brew install imagemagick
if [ -x "$(which convert)" ]; then
function convert-raw-to-jpg() {
local quality=${1:-80};
local max_dim=${2:-2650};
local source_files=${3:-\*.CR2};
echo "Usage: convert-raw-to-jpg [quality=80] [max-dimension-px=2560] [source=\*.CR2]";
echo "Converting all ${source_files} to JPEG (${quality} quality, ${max_dim}px max) to output/...";
mkdir -p output 2> /dev/null;
find . -type f -iname "${source_files}" -print0 | \
xargs -0 -n 1 -P 8 -I {} convert -verbose -units PixelsPerInch {} \
-colorspace sRGB -resize ${max_dim}x${max_dim} -set filename:new '%t-%wx%h' \
-density 72 -format JPG -quality ${quality} 'output/%[filename:new].jpg';
echo 'Done.';
}
fi;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment