php使用imagick给图片加水印的办法
发布时间:2022-02-23 18:53:31 所属栏目:PHP教程 来源:互联网
导读:?php $image = new Imagick(); $image-readImage(original.jpg); $watermark = new Imagick(); $watermark-readImage(/data/mark.png); // how big are the images? $iWidth = $image-getImageWidth(); $iHeight = $image-getImageHeight(); $wWidth = $wate
<?php $image = new Imagick(); $image->readImage("original.jpg"); $watermark = new Imagick(); $watermark->readImage("/data/mark.png"); // how big are the images? $iWidth = $image->getImageWidth(); $iHeight = $image->getImageHeight(); $wWidth = $watermark->getImageWidth(); $wHeight = $watermark->getImageHeight(); if ($iHeight < $wHeight || $iWidth < $wWidth) { // resize the watermark $watermark->scaleImage($iWidth, $iHeight); // get new size $wWidth = $watermark->getImageWidth(); $wHeight = $watermark->getImageHeight(); } // calculate the position $x = ($iWidth – $wWidth); $y = ($iHeight – $wHeight); //Cuoxin.com $image->compositeImage($watermark, imagick::COMPOSITE_OVER, $x, $y); header("Content-Type: image/" . $image->getImageFormat()); echo $image; ?> (编辑:ASP站长) 【免责声明】本站内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。 |
相关内容
未处理完善
-
无相关信息
最新更新