Skip to content

Instantly share code, notes, and snippets.

@innermond
Created January 26, 2018 07:15
Show Gist options
  • Save innermond/643f46e854157853cf6261a05a2965ef to your computer and use it in GitHub Desktop.
Save innermond/643f46e854157853cf6261a05a2965ef to your computer and use it in GitHub Desktop.
prepare images for pig.js
#!/bin/bash
# useit: ./.imagery <directory source> <dist directory>
# example: ./.imagery ~/Projects/printuridigital.ro/stock-images/pipes/ pipes
from="$1"
root="$2"
p20="$root/20"
p100="$root/100"
p250="$root/250"
p500="$root/500"
p800="$root/800"
# make folder structure
mkdir -p "$p20"
mkdir -p "$p100"
mkdir -p "$p250"
mkdir -p "$p500"
mkdir -p "$p800"
find "$from" -name "*.jpg" -type f -print0 | xargs -0i cp "{}" "$root"
#find "$root" -name "*.jpg" -type f -print0 | parallel --no-notice -0 -j +0 "convert {} -resize x20 $p20/{}"
mogrify -path "$p20" -thumbnail x20 "$root/*.jpg"
mogrify -path "$p100" -thumbnail x100 "$root/*.jpg"
mogrify -path "$p250" -thumbnail x250 "$root/*.jpg"
mogrify -path "$p500" -thumbnail x500 "$root/*.jpg"
mogrify -path "$p800" -thumbnail x800 "$root/*.jpg"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment