上传后调整图像大小 [英] Resize image after upload
问题描述
我希望在上传后以4种不同的格式调整图片大小。如果我将其调整到最适合(即纵横比),如果高度或宽度太大而某些图像太小,如果我将其调整为固定大小,则图像会偏斜。那么调整图像大小的最佳方法是什么呢?我目前正在使用imagemagik thumbnailImage()进行此操作,但我认为这是一个普遍的问题。什么是像谷歌或Facebook这样的网站。在这种情况下最好的做法是什么
I want images to resize after upload in 4 different formats. If i resize it to best fit(i.e aspect ratio) some images come too small if height or width is too large than the other and if i resize it to fixed size then images get skewed. So what is the best way to resize a image. I am currently doing this using via imagemagik thumbnailImage() but i think it's a general problem. What are sites like google or facebook doing. what is the best thing to do in that case
推荐答案
您可以使用调整大小功能在上传图像期间调整不同大小的图像。
例如:
You can use resize functionality for resize image in different size during upload image. For example:
include('SimpleImage.php');
$image = new SimpleImage();
$image->load($_FILES['uploaded_image']['tmp_name']);
$image->resizeToWidth(300);
$image->resizeToHeight(200);
$image->save('resizeImage.jpg'
同样,你可以保存不同大小的图片。
Similarly, you can save image in different size.
有关详细信息,请点击此处:
For more in detail you can find here:
http://sanjeevkumarjha.com.np/how-to-resize-and-crop-image/
这篇关于上传后调整图像大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!