问题
Possible Duplicate:
Resize a picture to a fixed size
How to resize an image in PHP?
回答1:
Try the GD and Image functions, or - if you want something more than just that - a library like ImageMagick.
回答2:
You may use imagemagick, call it via exec("convert ...") from php, copy it to the desired location and access it.
回答3:
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
回答4:
I'm using Image_Transform PEAR package for it. A ready-made thing that's pretty solid at this task.
回答5:
You may use codeigniter framework which provides you a lot of tools, including image manipulation. Otherwize, the main idea is to:
- open your picture (jpg for instance) with imagecreatefromjpeg()
- create a new picture using imagecreatetruecolor()
- use imagecopyresampled()
- finally to save it with imagejpeg().
回答6:
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!
来源:https://stackoverflow.com/questions/3004971/how-to-resize-an-image-using-php