Resize images with PHP, support PNG, JPG

前端 未结 7 1384
囚心锁ツ
囚心锁ツ 2020-12-08 01:37

I am using this class:

class ImgResizer {

function ImgResizer($originalFile = \'$newName\') {
    $this -> originalFile = $originalFile;
}
function resiz         


        
相关标签:
7条回答
  • 2020-12-08 02:17

    I've written a class that will do just that and is nice and easy to use. It's called
    PHP Image Magician

    $magicianObj = new imageLib('racecar.jpg');
    $magicianObj -> resizeImage(100, 200);
    $magicianObj -> saveImage('racecar_convertd.png', 100);
    

    It supports Read and Write (including converting) the following formats

    • jpg
    • png
    • gif
    • bmp

    And can read only

    • psd's

    Example

    // Include PHP Image Magician library
    require_once('php_image_magician.php');
    
    // Open JPG image
    $magicianObj = new imageLib('racecar.jpg');
    
    // Resize to best fit then crop
    $magicianObj -> resizeImage(100, 200, 'crop');
    
    // Save resized image as a PNG
    $magicianObj -> saveImage('racecar_small.png');
    
    0 讨论(0)
提交回复
热议问题