zoukankan      html  css  js  c++  java
  • php imagick svg转成jpg

    php imagick svg转成jpg

    <pre>
    public function svgtojpg()
    {
    $image = '<?xml version="1.0" standalone="no"?>
    <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
    "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

    <svg width="400" height="300" viewBox="0,0,40,30" style="border:1px solid #cd0000;" version="1.1"
    xmlns="http://www.w3.org/2000/svg">
    <rect x="0" y="0" width="40" height="30" fill="#cd0000"/>

    </svg>
    ';
    $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();
    }
    </pre>

  • 相关阅读:
    图床_shell命令passwd
    图床_shell命令usermod
    图床_shell命令groupadd
    图床_shell命令userdel
    图床_shell命令useradd
    图床_shell命令whereis
    图床_shell命令find
    图床_shell命令which
    图床_shell命令locate
    图床_shell命令free
  • 原文地址:https://www.cnblogs.com/newmiracle/p/11856293.html
Copyright © 2011-2022 走看看