MagickFilterImage and non-square filters?

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
Danack
Posts: 73
Joined: 2013-10-14T10:00:25-07:00
Authentication code: 6789

MagickFilterImage and non-square filters?

Post by Danack »

Is it required to call MagickFilterImage only with square, odd-sized filters (e.g. 3x3) or would non-square values be allowed? e.g. 3x4

The function seems to give an error if even sized filters are used (e.g. 4x4) but doesn't give an error for 3x4 size. However the image generated is highly corrupted, with valgrind reporting a large number of errors.

Asking in this forum, as if it's not allowed, then I think it should be checked for, just like the check against even sizes, to prevent image corruption.

==5112== Conditional jump or move depends on uninitialised value(s)
==5112== at 0x12D3843B: FilterImageChannel (quantum.h:94)
==5112== by 0x129C419B: MagickFilterImageChannel (magick-image.c:3400)
==5112== by 0x126DBB45: zim_imagick_filter (imagick_class.c:11556)
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: MagickFilterImage and non-square filters?

Post by snibgo »

magick-image.c function MagickFilterImage calls effect.c function FilterImage, which contains:

Code: Select all

  if ((kernel->width % 2) == 0)
    ThrowImageException(OptionError,"KernelWidthMustBeAnOddNumber");
There seems to be no restriction on kernel height. There is code in there that is activated by debug, so you might try that.
Danack wrote:... if it's not allowed, then I think it should be checked for, just like the check against even sizes, to prevent image corruption.
Agreed. A developer would need to comment.
snibgo's IM pages: im.snibgo.com
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: MagickFilterImage and non-square filters?

Post by magick »

We can reproduce the problem you posted and have a patch in ImageMagick 6.9.0-6 Beta, available by sometime tomorrow. Thanks.
Post Reply