Page 2 of 2

Re: Crop image from pdf

Posted: 2016-10-21T11:55:19-07:00
by fmw42
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

Re: Crop image from pdf

Posted: 2016-10-24T06:29:29-07:00
by ggoutfitters
Awesome, works great!

Thank you!!!

Re: Crop image from pdf

Posted: 2016-10-26T16:50:35-07:00
by anthony
I have always has an interest in extracting the non-vector components (raster images) of a PDF file in there 'native' density.

As you should know resizing any raster image always results in a loss of quality, Thus my interest.

A quick google search found "pdfimages" from the "xpdf" package does exactly that!