Page 1 of 1

fuzz and trim not working on a png

Posted: 2007-09-21T07:52:39-07:00
by brendan
Hello,
For some reason -fuzz x -trim in not working on a png. The png was converted from a ps image. If I specify a very large fuzz value the image is blank, but keeps the same size.

Re: fuzz and trim not working on a png

Posted: 2007-09-24T20:20:29-07:00
by anthony
A bug fix was added in a later release of image that makes a -trim that completely trims the WHOLE image return a 'one pixel missed image' instead of a blank image.

As for you actual problem can you give a pointer to a small example image, and the exact command you are trying. Also did you use percent with fuzz or not?
Without a percent symbol the -fuzz value is compiletime Q level dependant.

Re: fuzz and trim not working on a png

Posted: 2007-09-25T04:49:28-07:00
by brendan
The original ps, the first png, and the second png. edit: links to images removed

Commands:

Code: Select all

convert -colorspace RGB -density 288 -trim -filter box -support 1.5 -resize 40% -depth 8 -colors 256 +repage 00Z_EFINE_W3_042H.ps test.png
convert -fuzz 50% -trim -depth 8 -colors 256 test.png test2.png
The initial ps has a thin black border which the first -trim removes. When:

Code: Select all

convert -colorspace RGB -density 288 -trim -filter box -support 1.5 -resize 40% -trim -depth 8 -colors 256 +repage 00Z_EFINE_W3_042H.ps test.png
did not work I thought maybe I have to convert -trim ps to png to remove the black border and and convert-trim again to remove the whitespace. I also added the +repage thinking the postscript pagesize might be part of the issue. Ideally I wanted one command to do all the work so I ended up using -shave, which I did not want to do.

Re: fuzz and trim not working on a png

Posted: 2007-09-25T16:41:43-07:00
by anthony
Well I am not surprised it did not work.

You are not reading the image in BEFORE operating on it.
IM has a hard time figuring out the exact order of operations when you do that.

Gad... huge images Arrgg, I asked for small images ;-)

First test

Code: Select all

convert -colorspace RGB -density 288 00Z_EFINE_W3_042H.ps -trim +repage -filter box -support 1.5 -resize 40% t.png
No problems. A little fuzzy but that is what you get with a box filter and a larger 'blur support' t.png I generated and your given test.png matched fine.

Ok but trim fails. BUT looking at the trimmed image WITHOUT resizing shows
that there is a VERY thin line surrounding the converted PS image!!!!
You need to do a more complex trim...

test trim (output to display)

Code: Select all

convert -colorspace RGB -density 288 00Z_EFINE_W3_042H.ps -trim -shave 2x2 -trim +repage x:
Now that trims the image, removes the bounding box, then trims again, fully triming down to the image proper.

Final command...

Code: Select all

convert -colorspace RGB -density 288 00Z_EFINE_W3_042H.ps -trim -shave 2x2 -trim +repage -filter box -support 1.5 -resize 40% png8:test.png
The "png8:" taks care of the -depth and -colors requirements as that is the defination for a png8 image (like GIF but using PNG)

Re: fuzz and trim not working on a png

Posted: 2007-09-26T04:44:21-07:00
by brendan
Anthony,

Many thanks. I had not used that type of syntax before(obviously). Sorry about the large images, but I am not the person generating the ps images, so I had no way to exactly duplicate the problem. All ps images I ever generate myself(mostly from Matlab) never have this problem. These images are given to me as ps converted from NCAR graphics cgm.

Thanks again.

Re: fuzz and trim not working on a png

Posted: 2007-09-29T11:46:47-07:00
by el_supremo
Try specifying -bordercolor before -border.

Pete

Re: fuzz and trim not working on a png

Posted: 2007-09-30T17:28:56-07:00
by anthony
el_supremo wrote:Try specifying -bordercolor before -border.
There was no use of -border in this problem. this was trimming broders, not adding borders.

Re: fuzz and trim not working on a png

Posted: 2007-09-30T18:32:27-07:00
by el_supremo
There was no use of -border in this problem.
There was when I first started typing my reply to the message. When I sent my response, the message I was replying to had disappeared and changed to "Never mind". Curious.

Pete