SVG images blocked by gmail proxy
Asked Answered
T

1

53

It seems like the new gmail proxy for images doesn't work with SVG (gives a 404 error if you open the proxy url in a new tab.)

I haven't been able to find any documentation about supported/blocked file-types. Is SVG in gmail working for anyone else?

The only workaround I can think of is to generate a png of the svg on the server using PhantomJS - any other options?

Background:

This is for a webapp that sends daily summary emails, showing a graph covering the last 24 hours (so the svg is different each day, having it in the email saves the user the hassle of clicking through to the app.)

I know that the SVG images won't work in some email-clients, but it'll work for 95%, the rest can still click through to the webapp.

It was working fine in gmail up until the proxy change earlier this month (which has only just rolled out to Google Apps accounts at the end of the month.)

Trelu answered 28/12, 2013 at 14:21 Comment(0)
T
51

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 \
Trelu answered 11/1, 2014 at 16:27 Comment(4)
What a cheeky logic! - it's only 1 out of 100,000 as nobody wants to send something that is not supported ;) Maybe this should be heard louder…? Would you share a way to contact google support on that please (only asking there are multiple ways, I tried few - haven't got any response).Palmar
I got a reply via enterprise support for my Google Apps for Work account. If you have an account and are interested, then each person asking will help give it more priority... but to be honest I still wouldn't be very hopeful. One year on and the ImageMagick option is working fine for us - our needs aren't too complicated. I've added some sample code to my answer.Trelu
Also, to be fair to Google, even if they did support svg - most email clients won't. So demand would probably stay low.Trelu
The support is getting there. Maybe it’s time to talk to Google again. caniemail.com/features/image-svgSeften

© 2022 - 2024 — McMap. All rights reserved.