php使用imagick给图片加水印的办法
发布时间:2022-02-23 21:29:56 所属栏目: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; ?> (编辑:威海站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |