Skip to content

Instantly share code, notes, and snippets.

@brunogama
Forked from kampfgnu/convertPDFToPNG3x.sh
Created August 21, 2020 16:25
Show Gist options
  • Save brunogama/9202477cd90050668bac3262f45e9561 to your computer and use it in GitHub Desktop.
Save brunogama/9202477cd90050668bac3262f45e9561 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