[IPOL discuss] Vector graphics on IPOL: which format to use?

Nicolas Limare nicolas.limare at cmla.ens-cachan.fr
Thu Sep 8 04:01:53 CEST 2011


Hi Pascal,

> I have a question: How does one display an SVGZ file on a webpage?
> 
> On my dev.ipol page, I have an SVG image and a corresponding SVGZ:
> 
>    http://dev.ipol.im/~getreuer/out.svg
>    http://dev.ipol.im/~getreuer/out.svgz
> 
> the SVG image displays correctly in Google Chrome and Firefox but for
> some reason the SVGZ does not.  However, SVGZ should actually work in
> these browsers, for example you can verify this on GraphViz's gallery
> [1], which includes SVGZ figures.
>
> [1] http://www.graphviz.org/webdot/demo.html

I think it is a matter of server configuration. You can see the server
HTTP headers with the HEAD program (I only keep the useful lines hereafter).

The graphviz web server sayz to your browser "I am sending you a svg
file, compressed with gzip":
    Content-Encoding: gzip
    Content-Type: image/svg+xml

nil at nashi[09:08] ~ 
$ HEAD http://www.graphviz.org/cgi-bin/webdot/webdot/graphs/directed/KW91.dot.dot.svgz
200 OK
Content-Encoding: gzip
Content-Length: 1848
Content-Type: image/svg+xml

The IPOL server says to your browser "I am sending you a svg file"
    Content-Type: image/svg+xml)

nil at nashi[09:08] ~ 
$ HEAD http://dev.ipol.im/~getreuer/out.svgz
200 OK
Content-Length: 36725
Content-Type: image/svg+xml

And for the record, here are the headers for a svg file on IPOL:

$ HEAD http://dev.ipol.im/~getreuer/out.svg
200 OK
Content-Length: 284664
Content-Type: image/svg+xml

> Anyways, my problem is that the SVGZ file is not working on dev.ipol.
> I read that SVGZ requires that the server send a specific HTTP header
> to tell the browser that the content is encoded [2].  On Apache
> servers, this can be done by adding "AddEncoding gzip svgz" to the
> .htaccess file, and as a result, the server adds "Content-Encoding:
> gzip" to the header.  Does IPOL use Apache?

IPOL used nginx[1] on dev.ipol.im and Apache (until we can switch to
nginx) on www.ipol.im. So, you are rioght, the Content-Encoding: gzip
header must be added for .svgz files. I modified the configuration.

[1]http://wiki.nginx.org/

But we can do better. A standard feature of http servers is on-the-fly
gzip compression: if the browser is able to decode gzip-compressed
content, then the browser will compress the file and send it
compressed, for a faster transfer time. This on-demand compression was
enables for .html, .css and .js files, I added .svg. So, if you put a
.svg file on the server, it will be transmitted gzip-compressed, like
a .svgz file, if the browser can handle it, and uncompressed if the
browser can't receive gzipped content.

Here are the new server answers:
(I add a client header to tell the server I accept gzip content)

$ HEAD -H "Accept-Encoding: gzip" http://dev.ipol.im/~getreuer/out.svg
Content-Encoding: gzip
Content-Type: image/svg+xml
(he server can't send the Content-Length header, because it is
compressing on-the-fly)

$ HEAD -H "Accept-Encoding: gzip" http://dev.ipol.im/~getreuer/out.svgz
Content-Encoding: gzip
Content-Length: 36725
Content-Type: image/svg+xml

I only did this configuration for public_html folders on
dev.ipol.im. After testing, tell me if it is also needed for
* dev.ipol.im demos
* www.ipol.im
* www.ipol.im demos
(these are 3 different services, with 3 different configs)

> Alternatively, Is there any way to specify the content encoding of a
> link within an HTML file?  Say, something like...
> 
>    <a href="out.svgz [HTTP Header: Content-Type:
>    image/svg+xml; Content-Encoding: gzip]">

No I think this is not possible.

-- 
Nicolas LIMARE - CMLA - ENS Cachan    http://www.cmla.ens-cachan.fr/~limare/
IPOL - image processing on line                          http://www.ipol.im/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://tools.ipol.im/mailman/archive/discuss/attachments/20110908/a38a332b/attachment.pgp>


More information about the discuss mailing list