Resize image on server

后端 未结 3 1319
执笔经年
执笔经年 2020-12-20 10:10

I made a file that is in charge of uploading images, this images are then moved to a folder in the server. I think I can\'t resize the image directly in the $_FILES array so

3条回答
  •  醉酒成梦
    2020-12-20 11:07

    PHP comes built-in with the GD library.

    There are many functions available for manipulating images however there's no need to re-invent the wheel.

    Check out this gist for a simple image manipulation class - https://gist.github.com/880506

    Here's an example usage...

    $im = new ImageManipulator($_FILES['field_name']['tmp_name']);
    $im->resample(640, 480); // resize to 640x480
    $im->save('/path/to/destination/image.jpg', IMAGETYPE_JPEG);
    

提交回复
热议问题