Trying to generate proportionally cropped thumbnails at a fixed width/height with PHP GD

后端 未结 4 418
深忆病人
深忆病人 2021-01-25 01:59

I\'m trying to create a Thumbnail Generator in PHP with GD that will take an image and reduce it to a fixed width/height. The square it takes from the original image (based on m

4条回答
  •  野性不改
    2021-01-25 02:35

    I'm sorry if I'm offering an indirect answer. But you could try using this library: PHPThumb. It's very easy to use. It supports GD and has this function called adaptive resizing which resizes the image from the center.

    Here's a sample code from the docs for adaptive resizing:

    adaptiveResize(175, 175);
    $thumb->show();
    
    ?>
    

提交回复
热议问题