简体   繁体   English

如何在Codeigniter中针对单个图像上传将图像调整为较小的尺寸?

[英]How to resize an image to a smaller size in codeigniter for a single Image upload?

I want to resize the images during upload to a small size so that they take less time while loading on the website. 我想将上传过程中的图像调整为较小的尺寸,以便在加载到网站上时花费较少的时间。

And I also want to maintain the aspect ratio so that a portrait image doesn't get stretched and a landscape image doesn't get squeezed.That is without changing the actual dimensions of the image. 而且我还想保持宽高比,以使肖像图像不会被拉伸,风景图像也不会受到挤压,而这并没有改变图像的实际尺寸。

First convert your images to Jpeg, gif and png images as these are compressed images. 首先将图像转换为Jpeg,gif和png图像,因为它们是压缩图像。

In addition you can use ImageMagick to compress the image: Recommendation for compressing JPG files with ImageMagick 另外,您可以使用ImageMagick压缩图像: 建议使用ImageMagick 压缩JPG文件

An Image Manipulation class exists in CodeIgniter and can solve Your problem. ImageIgniter中存在一个图像处理类,可以解决您的问题。 Just read the official guide to learn more. 只需阅读官方指南即可了解更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM