使用php脚本+使用imagemagick而不使用命令行覆盖任何大小的图像 [英] Frame over any size of image using php script + with imagemagick without command line

查看:126
本文介绍了使用php脚本+使用imagemagick而不使用命令行覆盖任何大小的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我被困在某个地方,客户需要在产品图片上更改框架图像。表示如果图像尺寸为200 * 400,则图像框将应用于产品图像,如果产品图像为400 * 200,则同样的框架将应用于产品图像而无需任何手动信息(动态)。我认为可以使用imagemagick,因为我找到了这个网址( http:// www.fmwconcepts.com/imagemagick/picframe/index.php )但它正在使用命令行但我想要它没有命令行。

I have been stucked at some point where client needs to change the frame image over the product image. Means if image size is 200 * 400 then image frame will apply on the product image and if the product image is 400*200 then also same frame will be apply over the product image without any manual information(dynamically). I think it is possible using the imagemagick and for that I have found this url (http://www.fmwconcepts.com/imagemagick/picframe/index.php) but it is using command line But I want it without command line.

我正在制作类似给定页面的内容: - url: http://fineartamerica.com/产品/对话-laura-sue-canvas-print.html

I am making something like the given page :- url: http://fineartamerica.com/products/conversations-laura-sue-canvas-print.html

希望我已经很好地解释了我的问题。请帮帮我。
感谢您提前的支持。

Hope I have explained my problem well. Please help me out. Thanks for your support in advance.

推荐答案

我的代码在为我工作后有类似要求

i had a similar requirement following code worked for me

    $over = new Imagick($_SERVER['DOCUMENT_ROOT'] .'ks/new.png'); // load frame
    $pic = new Imagick($_FILES['pic']['tmp_name']); // load image
    $pic->resizeImage(1299,1722,Imagick::FILTER_LANCZOS,1); // resize your image to the size of your frame
    $pic->setImageFormat ("png"); //  set formate of final image
    $pic->compositeImage($over, Imagick::COMPOSITE_DEFAULT, (((($pic->getImageWidth()) - ($over->getImageWidth())))/2), (((($pic->getImageHeight()) - ($over->getImageHeight())))/2));
    $name=rand(1,10000000000);
    file_put_contents ("pictures/$name.png", $pic);
    $pic->destroy(); 

这篇关于使用php脚本+使用imagemagick而不使用命令行覆盖任何大小的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆