I am working on building gallery where the user uploads all the images. I had tried to use GD originally but found that it used way too much memory when dealing with images from a digital camera. So I have been looking into ImageMagick and ran into this problem.
我正在建立用户上传所有图片的画廊。我原本试图使用GD,但发现它在处理来自数码相机的图像时使用了太多的内存。所以我一直在研究ImageMagick并遇到了这个问题。
My end goal is to resize the image and then upload it. I am not sure if this is possible with ImageMagick or not. I have gotten it to resize the image after upload but it doesn't save the resized image, just the original size.
我的最终目标是调整图像大小,然后上传它。我不确定ImageMagick是否可以实现这一点。我已经得到它上传后调整图像的大小,但它不会保存调整大小的图像,只保存原始大小。
This is the code I am currently using: ($image is the path to the file on my server)
这是我目前使用的代码:($ image是我服务器上文件的路径)
$resource = NewMagickWand();
MagickReadImage($resource,$image);
MagickSetImageCompressionQuality( $resource, 100);
$resource = MagickTransformImage($resource,'0x0','660x500');
Any input would be appreciated,
Levi
Levi,任何意见都会受到赞赏
1 个解决方案
#1
Your code will send the modified image to the client (the web browser), but it will not save it to the server (replacing the original image, for example)
您的代码会将修改后的图像发送到客户端(Web浏览器),但不会将其保存到服务器(例如,替换原始图像)
To save the image, use:
要保存图像,请使用:
MagickWriteImage( $resource, 'new_image.jpg' );
#1
Your code will send the modified image to the client (the web browser), but it will not save it to the server (replacing the original image, for example)
您的代码会将修改后的图像发送到客户端(Web浏览器),但不会将其保存到服务器(例如,替换原始图像)
To save the image, use:
要保存图像,请使用:
MagickWriteImage( $resource, 'new_image.jpg' );