Epub readers failed to render SVGZ files

4 posts / 0 new
Last post

I was asked to use SVGz (compressed version of SVG) in ePub files,but when i tested the output,i found that the readers (readium,ADE,IBooks) failed to render the figures,i searched the web,found that SVGz need special http header to work on regular web apps by adding new content encoding,Is there anyway to do the same with epub ?

SVGZ means simply compression with gzip.
However EPUB archives are anyway typically compressed with zip, compression efficiency should be comparable, therefore there is no advantage in using gzip-compressed SVG inside EPUB archives.
I think, therefore there is no need to put compressed SVG into EPUB
(I use lot of SVG in EPUB and the compression with ZIP is ok).

SVG itself requires to be able to interpret gzip-compressed files.
Using a ZIP-archive however, this can be interpreted as a local file system, therefore it should be enough to end the file name with '.svgz' or '.svg.gz' to indicate the compression.
If viewers do not manage this either by analysis of the file name or the first few bytes of the file, they do not conform to the SVG requirements about this issue.
But indeed, if a web server sends such files, it has to expose such information about the content, because file name dependencies and content-sniffing is not defined under these conditions. In a local file system there is in general no other way, because they typically provide no reliable standard method to store metadata about files in a machine readable form.
EPUB itself does not provide a specific mechanism to indicate this manifest either and SVG indicates to use the same media type.
To resume: You do not need it, but it should work more or less. If not, send bug report to the developers of the viewer ;o)

Thanks for this informative answer, imma try to contact with readers developers'.

Other things you might consider about smaller file sizes for SVG documents - this can result in a file size reduction by a factor of two to ten:
a) if the files are created with programs like inkscape and not with a simple text editor by an advanced author, a script like scour can clean up a lot of nonsense in such files without influence on presentation.
b) typically programs like inkscape use a lot of digits in path data. Typically you do not need it. If the viewBox is large enough (width and height about 1000), integers are sufficient in path data. For this I use my own scripts to (rescale and) round path data to reduce file size. Due to the rounding, this can result in some now unnecessary path segments, therefore one can clean up the rounded file again with the script scour.

Secondary menu