在 1&1 主机上使用 imagemagick 调整 php 中的图像大小
当允许用户调整现代 12MP 或更高相机的图像大小时,我的内存不足。即使一些大小只有 900kb 的图片也会占用更多的内存空间,因为它是基于像素大小的(我认为)所以......
我可以通过 SSH 访问 1&1 共享服务器,并且按照他们的说明上传 imagemagick并将其配置/制作/安装到我服务器上的目录中。现在我必须在 php 中做什么才能做同样的事情,因为
$originalImage = imagecreatefromjpeg($src);
$finalImage = imagecreatetruecolor($newWidth,$newHeight);
imagecopyresampled($finalImage, $originalImage, 0, 0, 0, 0, $newWidth, $newHeight, $originalWidth, $originalHeight);
imagejpeg($finalImage,$saveDest,$jpeg_quality);
变量希望是不言自明的。我试图找到安装 imagick 扩展的方法,但当我读到有关 PECL 和 PEAR 的内容时,我真的迷失了方向,我真的不想以某种方式搞砸正在运行的 php 安装。
I am running out of memory when allowing users to resize images of modern day 12MP or higher cameras. Even some pictures that are only 900kb in size take up a lot more room in memory because it's based on pixel size (i think) so ...
I have SSH access to a 1&1 shared server and I followed their instructions to upload imagemagick and configure/make/install it into a directory on my server. Now what do I have to do in php to do the same thing as
$originalImage = imagecreatefromjpeg($src);
$finalImage = imagecreatetruecolor($newWidth,$newHeight);
imagecopyresampled($finalImage, $originalImage, 0, 0, 0, 0, $newWidth, $newHeight, $originalWidth, $originalHeight);
imagejpeg($finalImage,$saveDest,$jpeg_quality);
the variables are hopefully self explanitory. I was trying to find my way through installing the imagick extension but i got really lost when i read about PECL and PEAR and I really don't want to screw up the working php installation somehow.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
但请确保来自用户站点的所有变量都已转义。并且 $saveDest 可以由您的网络服务器写入。
变化很大,您会遇到相同的内存限制问题,因为 apache/php 正在调用一个脚本,该脚本将其内存使用限制为其父级。
But make sure you have all variables coming from user site escaped. And $saveDest is writable by your webserver.
Changes are high that you run in to the same memory limit problems, couse apache/php is invoking a script which limits its memory usage to its parent.
更新 php.ini 文件:
Update
php.ini
file: