Re: Crop image from pdf
Posted: 2016-10-21T11:55:19-07:00
try this using -depth 8
Code: Select all
infile="fifty.pdf"
convert "$infile[0]" -depth 8 -background white -flatten -alpha off -negate -threshold 0 \
-define connected-components:verbose=true -connected-components 8 null: |\
tail -n +2 | while read line; do
bbox=`echo "$line" | sed 's/^[ ]*//' | cut -d\ -f2`
color=`echo "$line" | sed 's/^[ ]*//' | cut -d\ -f5`
#echo "bbox=$bbox; color=$color;"
if [ "$color" = "srgb(255,255,255)" ]; then
convert "$infile[0]" -crop "$bbox" +repage result.png
break
fi
done