Page 1 of 1

Bug in 'point' resize?

Posted: 2010-09-25T17:25:14-07:00
by Drarakel
I tried to use '-filter point -resize' - with IM v6.6.4-6 Q16, on Windows XP.
It seems to work only sometimes:

Code: Select all

convert logo: -filter point -set option:filter:verbose 1 -resize 50% test1.bmp
convert test1.bmp test1.jpg
# filter = Point
# window = Box
# support = 0
# win-support = 0
# blur = 1
# blurred_support = 0
# B,C = 0,0
Image
And now:

Code: Select all

convert logo: -filter point -set option:filter:verbose 1 -resize 50% test2.jpg
Same filter properties, but no image:
Image
But it's not directly related to the output formats..
With "-sample" (which should produce the same result as "-filter point -resize" - right?), it always works ok. Example:

Code: Select all

convert logo: -sample 50% sample.jpg

Re: Bug in 'point' resize?

Posted: 2010-09-25T17:40:09-07:00
by anthony
Something is VERY strange alright. But I don't know what. BMP produces the right image though on my system it also produces an error. Other formats may not produce anything!

It is very weird.

Note -sample would not be effected as it implements a point filter in a faster more direct way.

Re: Bug in 'point' resize?

Posted: 2010-09-25T17:55:04-07:00
by Drarakel
Yeah, it's strange that the BMP output generated a working image - especially since the direct output from IM shows again no colors:

Code: Select all

convert logo: -filter point -resize 50% -format "%c" histogram:info:-
76800: ( 0, 0, 0) #000000 black
:?

It seems that the bug came with version 6.6.4-2.

Re: Bug in 'point' resize?

Posted: 2010-09-25T18:10:24-07:00
by anthony
Ok found the fault.

Expert Explanation...
A Box function is meant to return a value or 1.0 if the sample is within 'support' distance of center of the sampling area.
However Point filter has a 'zero' support, so when it calls on a Box weighted points have a zero weighting -- BLACK

In other words the box filter was failing when it is used as the weigthing function with zero support -- Point filter

Before the recent spate of resize filter updates the Box Filter function always returns a weight os 1.0 regardless
of the support. That is It relied on the API client (ResizeImage() in this case) to only request samples within the support range.

I have removed that weighting function limitation, and restored 'Box' to always return a 1.0 weight for all sample requests, as it did previously. I have also pleased a note to this effect in the code to prevent it becoming 'limited' in future.

It broke around version 6.6.4-0 it should be fix in the next release 6.6.4-7
I have also updated the verbose output to show that internally the weighting function is really a 'Box' (with zero support) when a 'Point' filter is requested.

Code: Select all

convert logo: -filter point -set option:filter:verbose 1 -resize 50% test.jpg
Now returns the correct image, with a verbose response of...
#
# Resize Filter (for graphing)
#
# filter = Box
# window = Box
# support = 0
# win-support = 0
# blur = 1
# blurred_support = 0
# B,C = 0,0
#
0.00 1
0.00 0
Previously (with the bug still in place) those last two values would have been both a zero value - a direct indication of a bad weighting function.

Re: Bug in 'point' resize?

Posted: 2010-09-25T18:15:09-07:00
by anthony
I have no idea however why BMP would generate a correct image!! That was non-sensical and probably points to another bug somewhere else.

The Error I got for BMP generated images was...
convert: length and filesize do not match `/tmp/magick-XXBYWe5H' @ error/bmp.c/ReadBMPImage/790.
However that error has also vanished with the fix and the image is still producing a correct looking result.

Perhap 'BMP' actually makes its own internal call to ResizeImage()... Hmmmm.... Doesn't seem to!

Re: Bug in 'point' resize?

Posted: 2010-09-25T18:24:41-07:00
by magick
We can reproduce the problem you posted and have a patch in ImageMagikc 6.6.4-7 Beta available by sometime tomorrow. Thanks.

Re: Bug in 'point' resize?

Posted: 2010-09-25T21:09:34-07:00
by Drarakel
anthony wrote:The Error I got for BMP generated images was...
convert: length and filesize do not match `/tmp/magick-XXBYWe5H' @ error/bmp.c/ReadBMPImage/790.
I didn't get that message with my Win32 Q16 binary.
It seems (looking at the source) that IM checks the compression and the file size that's stored in the BMP header. On my system, the header values in the file from the first example look ok. But: The compression that's used here is RLE (8 bit), and this compression has issues in BMP. (See report. Though these issues should lead to real errors only rarely.) Of course, this doesn't explain why the BMP file (in this example) contained the 'real' image in the first place. Strange thing.

Anyway.. Regarding the point filter issue:
Thanks for your explanations and for the fix!

Re: Bug in 'point' resize?

Posted: 2010-09-25T21:35:13-07:00
by fmw42
FYI: I found that one of my scripts was broke when using -filter point -resize, also, earlier today in IM 6.6.4.6 Q16 Mac OSX Tiger, but did not have time to report the error until just now. Glad others found it, too, and reported it.