使用外部工具从 php 缩放图像
在 php 项目中,我遇到问题,我的提供程序不允许我将脚本的内存限制设置得更高。因此,如果用户上传一个巨大的图像文件,并且我尝试缩小它以确保其在服务器上的安全,我的脚本就会中断。
我的想法是运行 exec() 命令来使用外部工具,但没有找到任何示例。可以这样做吗?或者我应该在上传之前尝试使用javascript缩小图像?
还是有其他方法可以处理,我什至没有想过..?
感谢您的帮助!
In a php project I have the problem, that my provider doesn't allow me to set the memory-limit of my script higher. Therefore my script breaks if a user uploads a huge image file and I try to scale it down to safe it on the server.
My idea was to run an exec()
command to use an external tool but did not find any examples. Is it possible to do so? Or should I try to scale the image down before upload, using javascript?
Or is there an other way to handle, I haven't even thought about..?
Thanks for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用具有调整大小/缩放功能的客户端上传程序。这将确保大图像在到达您的服务器之前被缩小。 JumpLoader 是一个不错的选择。
Use a client-side uploader with resizing/scaling capabilities. This will make sure that big images are scaled down before reaching your server. JumpLoader is a good one.
您可以尝试
查看ImageMagick是否可用。
You can try a
to see whether ImageMagick is available.