How to resize an image using PHP? [duplicate]

眉间皱痕 提交于 2019-12-02 05:06:31

Try the GD and Image functions, or - if you want something more than just that - a library like ImageMagick.

You may use imagemagick, call it via exec("convert ...") from php, copy it to the desired location and access it.

You can also do like I do and use a lightweight framework like flourishlib.com where everything is nicely wrapped in a class fImage, example from documentation:

// Saving as a 60 quality JPEG
$image2 = new fImage('./example.gif');
$image2->resize(250, 0);
$image2->saveChanges('jpeg', 60);

It will work with both GD and ImageMagick

I'm using Image_Transform PEAR package for it. A ready-made thing that's pretty solid at this task.

You may use codeigniter framework which provides you a lot of tools, including image manipulation. Otherwize, the main idea is to:

Here is the code to a Image resize script which i wrote a while back. It resizes the image and keeps the aspect ratio.

This script uses the core GD library to resize. So hopefully your host already got it installed.

I did some fast translation on the documentation from swedish to english. So it might not be perfect.

Hope it works!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!