我找到了一个很好且快速实现的东西。它工作得很好,但在上传图像之前,我想将它们调整为最大宽度,同时保持比例。
假设我正在上传宽度为5000px的图像,我希望将其调整为1000px宽度,但保持高度比例,然后保存最终图像。
示例用法:
/* shrink() - will shrink/resize the image according to the given dimensions (in pixels)
* NOTE, a folder called 'shrinked_images' will be created first to store the uploaded image
*/
$bulletProof
->fileTypes(array("jpg", "gif", "png", "jpeg"))
->uploadDir("shrinked_images")
->shrink(array("height"=>100, "width"=>200))
->upload($_FILES["pictures"]);
GitHub:
https://github.com/samayo/bulletproof
我已阅读文档,但找不到有关调整大小的内容。在代码中能找到的只有缩小函数,但无法看到如何添加保持比例选项?
谢谢。Craig。