#!/bin/sh

# example: scale-image 300 test/file.jpg
# example: find | xargs scale-image 300

width=$1
path=$2
target_path="scaled-images/$path"

if test -f "$target_path"
then
  exit 0
fi

mkdir -p $(dirname "$target_path") &&
gm convert -size $width\>x "$path" -resize $width\>x +profile "*" "$target_path"