标签: bulletproof

使用BulletProof上传类时,在上传之前调整图像大小

发现这很好,很快实现.它工作得很好,但在上传图像之前我想要它,它们被调整到最大宽度但保持比率.

假设我正在上传宽度为5000像素的图像,我希望将其调整为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"]);
Run Code Online (Sandbox Code Playgroud)

GitHub:

https://github.com/samayo/bulletproof

我已阅读了文档,但无法找到有关调整大小的内容.我能在代码中找到的只是缩小函数,但是无法看到如何添加保持率选项?

谢谢.克雷格.

php image class image-uploading bulletproof

13
推荐指数
1
解决办法
685
查看次数

标签 统计

bulletproof ×1

class ×1

image ×1

image-uploading ×1

php ×1