Page 1 of 1

trim does not remove the black border from JPEG

Posted: 2007-09-02T02:07:21-07:00
by wizzofoz
I've done some testing with the -trim option with self created files (Fireworks) and it seemed to work ok but when I try to trim my scanned images the border does not disappear.

I use (from the windows command prompt) the following command:

convert -trim input.jpg output.jpg

Please ask me for an example file if you want to test it

Re: trim does not remove the black border from JPEG

Posted: 2007-09-02T07:23:31-07:00
by Bonzo
I have never used trim but try adding +repage

Code: Select all

convert input.jpg -trim +repage output.jpg

Re: trim does not remove the black border from JPEG

Posted: 2007-09-02T07:27:57-07:00
by el_supremo
A scanned image probably doesn't have a border with a pure colour. Add -fuzz 20 to your command and see how much it trims off. Then play with the fuzz value to get the right amount trimmed off.
See: http://imagemagick.org/script/command-l ... s.php#fuzz

Pete

Re: trim does not remove the black border from JPEG

Posted: 2007-09-02T07:37:22-07:00
by wizzofoz
Sorry to tell that both of your solutions do not work.

If you want to test is yourself, please tell me where to send some test images ...

Re: trim does not remove the black border from JPEG

Posted: 2007-09-05T19:45:41-07:00
by anthony
+repage does not work for JPEG, as this file format does not use virtual canvas information. PNG does but only partially, GIF definably does.

The problem is JPG is lossy. Colors are not EXACTLY as you thing they are.

As such to trim you need to tell IM to allow 'near' colors too. To do this add a 'fuzz factor.

Code: Select all

     -fuzz 1% -trim
See IM Examples, Fuzz Factor...
http://www.imagemagick.org/Usage/color/#fuzz