bug in -distort Barrel

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
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

bug in -distort Barrel

Post by el_supremo »

The documentation says that the fourth argument is optional and will be computed if it is missing, but if only 3 arguments are specified to barrel distortion, IM prints an error message.
In distort.c at line 1237 is this code:

Code: Select all

      if ( number_arguments != 4 && number_arguments != 6 &&
           number_arguments != 8 && number_arguments != 10 ) {
        coeff=(double *) RelinquishMagickMemory(coeff);
        (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
               "InvalidArgument", "%s : '%s'", "Barrel(Inv)",
               "number of arguments" );
        return((double *) NULL);
      }
      /* A,B,C,D coefficients */
      coeff[0] = arguments[0];
      coeff[1] = arguments[1];
      coeff[2] = arguments[2];
      if ( number_arguments == 3 || number_arguments == 5 )
        coeff[3] = 1 - arguments[0] - arguments[1] - arguments[2];
      else
         coeff[3] = arguments[3];
The first if statement causes an error if there aren't 4, 6, 8, or 10 arguments. But the next if statement tests for the case where there are 3 or 5 arguments and, if so, computes the missing value.

The first if statement should allow the number of arguments to be 3,4,5,6,8 or 10.

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: bug in -distort Barrel

Post by magick »

We can reproduce the problem you posted and have a patch in ImageMagick 6.6.1-Beta available by sometime tomorrow. Thanks.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: bug in -distort Barrel

Post by fmw42 »

There was some discussion of this issue via email in January, while Anthony was in china. Wolfgang Hugemann pointed it out. I suspect Anthony has been too busy getting back to normal to get around to fixing it, since he has been back. His comment was that it had been original designed to do that, but may have broken sometime afterwards.
Post Reply