Cropping black borders from manuscript

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
toppah
Posts: 1
Joined: 2015-10-24T06:56:40-07:00
Authentication code: 1151

Cropping black borders from manuscript

Post by toppah »

Dear all,

I read a lot on the forums before posting here but I cannot solve my issue, so I hope you can help me dealing with this matter:
I simply would like to remove black borders around my images produced from a digital camera which take pictures of ancient manuscripts.

This is my sample image: https://www.dropbox.com/s/imrs6unowxdte ... X.tif?dl=0

This is the command I am now using and it actually works!

convert IMGP2341DX.tif -bordercolor black -border 1 -fuzz 40% -fill black -draw "color 0,0 floodfill" -shave 1x1 prova.tiff
convert -fuzz 95% -trim prova.tiff fine.tiff

The problem arises when I se up a bash script to loop through the files, the command above does not give the same result.

This is my script: https://www.dropbox.com/s/3eug0mk761x8d ... ge.sh?dl=0


the problem seems to be the following line:
convert ${f} -monitor -bordercolor black -border 1 -fuzz 40% -fill black -draw "color 0,0 floodfill" -shave 1x1 shaved-tmp${f}

if I launch the script with bash -x I see that the command is launched as this:

convert IMGP2341DX.tif -bordercolor black -border 1 -fuzz 40% -fill black -draw 'color 0,0 floodfill' -shave 1x1 prova.tiff

instead of:
convert IMGP2341DX.tif -bordercolor black -border 1 -fuzz 40% -fill black -draw "color 0,0 floodfill" -shave 1x1 prova.tiff

What do you think?

Thanks a lot,

L.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Cropping black borders from manuscript

Post by snibgo »

What version of IM are you using?
toppah wrote:... the command above does not give the same result.
What is different about the result? Please post the two versions of the image.

I notice the file IMGP2341DX.tif is encoded in AddobeRGB. That won't cause a problem to IM, but some viewers will ignore this and assume the image is sRGB.
snibgo's IM pages: im.snibgo.com
Post Reply