Extent and geometry

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
User avatar
rmabry
Posts: 148
Joined: 2004-04-13T11:25:27-07:00

Extent and geometry

Post by rmabry »

Below is the latest code in Magick.xs, around line 9695. Notice the placement of these two lines, about 15 lines into the snippet:

Code: Select all

geometry.x=(-geometry.x);
geometry.y=(-geometry.y);
This negation puzzles me, but no matter; it is in the regular API, too, not just in PerlMagick. But it seems to me that those two lines need to be moved down, perhaps just before the call to ExtentImage. Otherwise there is a difference between entering x and y separately versus embedded in a geometry string.

Code: Select all

        case 93:  /* Extent */
        {
          if (attribute_flag[7] != 0)
            image->gravity=(GravityType) argument_list[7].integer_reference;
          if (attribute_flag[0] != 0)
            {
              int
                flags;

              flags=ParseGravityGeometry(image,
                argument_list[0].string_reference,&geometry,exception);
              if (geometry.width == 0)
                geometry.width=image->columns;
              if (geometry.height == 0)
                geometry.height=image->rows;
              geometry.x=(-geometry.x);
              geometry.y=(-geometry.y);
            }
          if (attribute_flag[1] != 0)
            geometry.width=argument_list[1].integer_reference;
          if (attribute_flag[2] != 0)
            geometry.height=argument_list[2].integer_reference;
          if (attribute_flag[3] != 0)
            geometry.x=argument_list[3].integer_reference;
          if (attribute_flag[4] != 0)
            geometry.y=argument_list[4].integer_reference;
          if (attribute_flag[5] != 0)
            image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
              QuantumRange);
          if (attribute_flag[6] != 0)
            (void) QueryColorDatabase(argument_list[6].string_reference,
              &image->background_color,exception);
          image=ExtentImage(image,&geometry,exception);
          break;
I discovered this when an old program suddenly didn't run anymore. If I negate the x and y it works, but it makes no sense (to me) to do that. That is, the following Perl code used to work.

Code: Select all

	 $subImage->Extent(width => 2*$r+1, height => 2*$r+1, x => $x0-$r, y => $y0-$r); 
Both of these now work, but the first seems wrong:

Code: Select all

	 $subImage->Extent(width => 2*$r+1, height => 2*$r+1, x => -($x0-$r), y => -($y0-$r)); 

Code: Select all

	my $extGeom = sprintf("%dx%d+%d+%d", 2*$r+1, 2*$r+1, $x0-$r, $y0-$r);
	$subImage->Extent(geometry => $extGeom); 
Bug?

Rick
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Extent and geometry

Post by magick »

We'll get a patch into ImageMagick 6.6.4-2 Beta by sometime tomorrow to fix the problem you reported. Thanks.
Post Reply