php imagick svg转成jpg

时间:2022-03-03 21:15:30
php imagick svg转成jpg

  public function svgtojpg()
    {
        $image    = '<?xml version="1.0" standalone="no"?>



';
        $filename = 'ef.jpg';
        /*  $image    = stripslashes($_POST['json']);
        $filename = $_POST['filename'];*/
        $unique = time();
        $im     = new \Imagick();
        $im->readImageBlob($image);
        $res     = $im->getImageResolution();
        $x_ratio = $res['x'] / $im->getImageWidth();
        $y_ratio = $res['y'] / $im->getImageHeight();
        $im->removeImage();
        $im->setResolution($width_in_pixels * $x_ratio, $height_in_pixels * $y_ratio);
        $im->readImageBlob($image);
        $im->setImageFormat("jpeg");
        $im->writeImage(__DIR__ . '/../../../Public/moban/images/1/humourised_'. $filename);
        $im->clear();
        $im->destroy();
    }


查看原文: http://newmiracle.cn/?p=2514