Skip to content

Instantly share code, notes, and snippets.

@sgraessle
Last active February 15, 2024 05:41
Show Gist options
  • Save sgraessle/bbba040ece9f5943c5d1 to your computer and use it in GitHub Desktop.
Save sgraessle/bbba040ece9f5943c5d1 to your computer and use it in GitHub Desktop.
Generate multiple image sizes from a directory tree.
#!/bin/bash
if [ $# -ne 2 ]
then
echo usage: $(basename $0) source_path dest_path
exit
fi
path=$2/$(dirname $1)
mkdir -p $path
for z in 128 256 512
do
sips -Z $z --out $path/$(basename $1 .png)_$z.png $1
done
@sgraessle
Copy link
Author

Use the OS X command-line utility sips to generate different-sized images from a directory tree of .png files. The new file names have sizes appended and saved to the dest_path with similar directory structure. This needs to run from the base directory of your source tree.

find . -name \*.png -exec ../resize.sh {} ../resized \;

If you have recent aws installed (brew install awscli, then aws configure) you can update S3 like so:

aws s3 sync . s3://assets.nbabreakaway.com/cards --acl public-read --cache-control max-age=3600

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