Bug in Image.Image->bitscale()?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Bug in Image.Image->bitscale()?

larcky
Hi

Using Pike 8.0 (release 182) I noticed the Image.Image->bitscale() method doesn't work as per the documentation.
This says if you give it two ints for the new image size (xsize and ysize) and one of them is 0, it'll preserve the aspect ratio of the original image.  Actually it just sets that 0 to a 1.  I kludged a fix for my own use by changing src/modules/Image/image.c:

FROM
  if( newx < 1 ) newx = 1;
  if( newy < 1 ) newy = 1;

TO:
  if( newx < 1 )
  {
      newx = 1.0 * newy / oldy * oldx;
      newx = MAXIMUM(1, newx);
  }
  if( newy < 1 )
  {
      newy = 1.0 * newx / oldx * oldy;
      newy = MAXIMUM(1, newy);
  }

Thanks.
Loading...