使用Imagick进行矩形图像转换

问题描述 投票:-1回答:1

矩形图像转换使用Imagick。尺寸为720X820。但是通过imagick获取正方形图像。如何使用Imagick

将图像转换为矩形
list($srcWidth,$srrHeight)=@getImageSize($aws_image1080);
echo "srcWidth->".$srcWidth;
echo "srrHeight->".$srrHeight; 
echo  "req_width->".$req_width;
echo  "req_height->".$req_height;

$widthBorder=$srrHeight-$srcWidth;
#echo (int)$req_height-(int)$req_width;exit;
$borderSetW=round($widthBorder/2);
$borderSetH=0;
$borderSet="-border ".$borderSetW."X".$borderSetH."";
echo "111";
echo "<br />";
echo "dsaf".$borderSet;

预先感谢

php imagick
1个回答
0
投票

Here所有功能:

function rectangle($strokeColor, $fillColor, $backgroundColor)
    {
        $draw = new \ImagickDraw();
        $strokeColor = new \ImagickPixel($strokeColor);
        $fillColor = new \ImagickPixel($fillColor);

        $draw->setStrokeColor($strokeColor);
        $draw->setFillColor($fillColor);
        $draw->setStrokeOpacity(1);
        $draw->setStrokeWidth(2);

        $draw->rectangle(200, 200, 300, 300);
        $imagick = new \Imagick();
        $imagick->newImage(500, 500, $backgroundColor);
        $imagick->setImageFormat("png");

        $imagick->drawImage($draw);

        header("Content-Type: image/png");
        echo $imagick->getImageBlob();
    }
© www.soinside.com 2019 - 2024. All rights reserved.