Search code examples
phpthumbnailspixeldimensions

PHP: Create thumbnail of top left of picture


I have this large png file and now I want to create a thumbnail of the upper left corner.

The png is like 600x1000 pixels, the thumbnail should be top left 400x300 pixels of it.

Would be awesome if you can help me out! (Since google only shows how to thumbnail the ENTIRE picture)


Solution

  • imagecopyresampled( $top_left_image_thumb,       //cropped thumbnail image
                        $original_image,             //original image
                        0, 0, 0, 0,                  //top-left corners
                        $thumb_width, $thumb_height, //dst dimensions 
                        400, 300                     //src subarea dimensions
                       );