PHP code example of bartdecorte / imagick-svg
1. Go to this page and download the library: Download bartdecorte/imagick-svg library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bartdecorte / imagick-svg example snippets
BartDecorte\ImagickSvg\Svg;
// local path or URL
$svg = new Svg(__DIR__ . '/esign-logo.svg');
$draw = new ImagickDraw();
$width = 1000;
$height = $width * ($svg->height() / $svg->width());
$draw->scale($width / $svg->width(), $height / $svg->height());
$draw->setStrokeAntialias(true);
$draw->setTextAntialias(true);
$draw = $svg->draw($draw);
$imagick = new Imagick();
$imagick->newImage($width, $height, '#00000000', 'png');
$imagick->drawImage($draw);
@ob_clean();
ob_start();
header('Content-Type: image/png');
print $imagick->getImageBlob();
header('Content-Length: '. ob_get_length());
ob_end_flush();