I've heard back from Google support, and they've confirmed there are currently no plans to support SVG images in the proxy. They said they account for only 1 in 100,000 email images.
Apart from PhantomJs, an option for simpler svg is the php plugin ImageMagick.
Here's some sample code to get you started:
header("Content-Type: image/png");
header("Content-Disposition: inline;");
if (empty($svg)) {
readfile("invisibleImage.png", true);
} else {
//TODO: You'll probably want to set headers to cache the returned image
$filepath = "/path/to/where/images/are/cached/";
if (!file_exists("$filepath$svgName.png")) {
if (!is_dir($filepath)) {
mkdir($filepath, 0700, 1);
}
file_put_contents("$filepath$svgName.svg", $svg);
$cmd = "rsvg-convert $filepath$msk.svg > $filepath$svgName.png";
exec($cmd);
unlink("$filepath$svgName.svg");
}
readfile("$filepath$svgName.png");
}
You'll want to install at least some of the following:
apt-get install librsvg2-bin libpng3 imagemagick libpng12-dev
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…