Initilizing an image from a string intead of a file
Posted: 2013-01-28T15:37:24-07:00
I am running ImageMagick from the command line, via PHP's exec() function. I need to convert an SVG image to PNG. Something like this:
exec('-convert image.svg image.png');
I need to get the contents of image.svg, and manipulate them before converting the file to PNG. Do I have to save the altered image.svg to a new file, or is there a way to write the PNG file from a string?
For example I would get the file into the $image variable like this:
$image = file_get_contents('image.svg');
Then I would manipulate $image, based on an outside input. How can I directly convert $image to a PNG image without having to save it first as an SVG image? Is that even possible?
exec('-convert image.svg image.png');
I need to get the contents of image.svg, and manipulate them before converting the file to PNG. Do I have to save the altered image.svg to a new file, or is there a way to write the PNG file from a string?
For example I would get the file into the $image variable like this:
$image = file_get_contents('image.svg');
Then I would manipulate $image, based on an outside input. How can I directly convert $image to a PNG image without having to save it first as an SVG image? Is that even possible?