Created
December 1, 2015 07:30
-
-
Save drewlustro/03f228415e6886045f6d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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