I am sending a string representation of an SVG file to the server and using Imagick to turn this into a jpeg in the following manner:
$image = stripslashes($
I was looking for a solution, and i found this just after reading this post, and work like a charm:
$im = new Imagick();
$im->readImage("/path/to/image.svg");
$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->readImage("/path/to/image.svg");
// Now you can do anything with the image, such as convert to a raster image and output it to the browser:
$im->setImageFormat("png");
header("Content-Type: image/png");
echo $im;
Credits go to the author of that comment in php manuals page.