Page 1 of 1

bug in -distort Barrel

Posted: 2010-03-27T16:13:52-07:00
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

Re: bug in -distort Barrel

Posted: 2010-03-27T16:29:17-07:00
by magick
We can reproduce the problem you posted and have a patch in ImageMagick 6.6.1-Beta available by sometime tomorrow. Thanks.

Re: bug in -distort Barrel

Posted: 2010-03-27T17:25:00-07:00
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.