Why does my Image stretch when I crop it?

Posted by q234e on Stack Overflow See other posts from Stack Overflow or by q234e
Published on 2010-06-16T12:53:03Z Indexed on 2010/06/16 13:12 UTC
Read the original article Hit count: 132

Filed under:
|

I am using the following code snippet in order to crop a image?

   function crop($width,$height) {
       $new_image = imagecreatetruecolor($width, $height);
       imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $this->getWidth(), $this->getHeight(), $width, $height );
       $this->image = $new_image;
   }

Here, $this->image is the original image $this->getWidth() and $this->getHeight() holds the original dimensions of the picture, where as $width and $height, is the crop area.

But for some reason, the crop image is resized(we can almost say it is resized).

How to fix this?

© Stack Overflow or respective owner

Related posts about php

Related posts about gd