Skip to content

Instantly share code, notes, and snippets.

@yoya
Last active September 7, 2017 09:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yoya/db0851416f3462bcdd0a6a7fd7fc014f to your computer and use it in GitHub Desktop.
Save yoya/db0851416f3462bcdd0a6a7fd7fc014f to your computer and use it in GitHub Desktop.
AI (Adobe Illustrator) BitmapImage & Text Extractor.
#! /bin/sh
# AI (Adobe Illustrator) BitmapImage & Text Extractor.
# only "PDF compatible":true
# (c) 2017/09/07- yoya@awm.jp
# require)
# % brew install fswatch poppler epstool
# execute) MacOS
# % fswatch -0 ~/QUANT/working | xargs -0 -n 1 sh ./ai_extract.sh
# test)
# % cp -r AIFiles/* ~/QUANT/working/.
filename=$1
if [ ! -e "$filename" ]; then
exit 0;
fi
echo $filename
dirname=`dirname "$filename"`
basename=`basename "${filename%.*}"`;
output="$dirname/$basename";
case "$filename" in
*\.[aA][iI])
pdfimages -png -j "$filename" "$output"
pdftotext "$filename" "$output".txt
;;
*\.[eE][pP][sS])
epstool --bitmap "$filename" "$output".png # pnm
mogrify "$output".png
;;
*)
# echo "Not .ai .eps suffix"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment