Page 1 of 1

convert and trim problem

Posted: 2013-04-01T03:08:22-07:00
by bensto
I want to remove all white pixel border (!) lines inside a picture around the actual content.

For that I enter the following command:

convert.exe -trim D:\tmp\2.jpg and got the following error (under 64bit Win7):

convert.exe: no images defined `D:\tmp\2.jpg' @ error/convert.c/ConvertImageCommand/3085.

Hmm, the picture exists!. Whats wrong?

Other related question: Assume I dont want not only to remove/trim pure white color lines but also almost white lines.
Lets say I want to remove lines whose "whiteness" is maximum 3% different from "pure" white.

How can I achieve this?

Ben

Re: convert and trim problem

Posted: 2013-04-01T09:35:34-07:00
by fmw42
Your syntax is in error. Properly, you should open the input image before trimming or most any other operation.

convert image -fuzz 3% -trim +repage output

see
http://www.imagemagick.org/Usage/crop/#trim

Note the +repage (to remove the virtual canvas) is not needed for jpg output, but could be needed for gif, png and tif

Re: convert and trim problem

Posted: 2013-04-01T11:23:22-07:00
by snibgo
To expand slightly on fmw's explanation: convert needs an input file and an output file. They can be the same name, but you must provide them both. So your command could be:

Code: Select all

convert D:\tmp\2.jpg -fuzz 3% -trim +repage D:\tmp\2.jpg

Re: convert and trim problem

Posted: 2013-04-03T16:39:49-07:00
by anthony
UNLESS you use "mogrify" that reads processes and writes images to the same file name, but (currently) only allowing 'simple' image operations. Note that -trim is a simple image operation.

Code: Select all

mogrify -fuzz 3% -trim +repage D:\tmp\2.jpg