Skip to content

Instantly share code, notes, and snippets.

@kampfgnu
Created March 4, 2018 09:52
Show Gist options
  • Save kampfgnu/fd93208b57f03b7f9e23f3b4746c5a1f to your computer and use it in GitHub Desktop.
Save kampfgnu/fd93208b57f03b7f9e23f3b4746c5a1f to your computer and use it in GitHub Desktop.
convert vector pdf to iOS image assets
#!/bin/bash -e
# convert vector pdf to iOS image assets
# copy this script to the folder where the pdf files live and run "./convertPDFToPNG3x.sh" in terminal.
# this will generate [filename]@3x.png, [filename]@2x.png and [filename].png images in the same folder
# Ensure we're running in location of script.
cd "`dirname $0`"
for f in *; do
if [[ $f == *.pdf ]];
then
convert -density 216 "$f" "${f//.pdf/@3x.png}"
convert -density 144 "$f" "${f//.pdf/@2x.png}"
convert -density 72 "$f" "${f//.pdf/.png}"
fi
done
echo "Complete"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment