0

I have saved a complete HTML page from a server using Chrome.

When I load the local file again in Chrome, the SVGZ images do not render and instead shows a broken image icon.

  • Double checking the file and loading again from the original server, I find that the SVGZ loads just fine

  • If I load just the local image file on its own, I get prompted to save the image

  • If I edit the local image filename extension to .SVG, and load on its own, it renders just fine

  • If I then edit the HTML file to refer to the renamed file with the .SVG extension, then the entire page and image all loads correctly


I know this is not strictly a programming issue, but in doing a lot of searching, I have found more closely related answers here on StackOverflow than on say AskUbuntu.

This answer provides the best clue I have found thus far:

Chrome not rendering SVG referenced via <img> tag

I came here because I had a similar problem, the image was not being rendered. What I found out was that the content type header of my testing server wasn't correct. I fixed it by adding the following to my .htaccess file:

AddType image/svg+xml svg svgz
AddEncoding gzip svgz

So I am guessing that the problem lies somewhere with:

  • when loaded from the server, the content type is correctly specified
  • when loaded from my local file, the content type is NOT correctly specified

Is there any way to resolve this ?

Can I "mimic" the .htaccess mime type and encoding by changing a Chrome setting ?

Any advice is appreciated.

Community
  • 1
  • 1
TaoRich
  • 87
  • 1
  • 9

1 Answers1

2

I created a test HTML file with an <img> that loads a .svgz file. It worked okay (Chrome on Win7).

Check that your .svgz file is actually a gzipped SVG file, and not something else. For instance I suspect that it is actually a normal SVG file but with a ".svgz" extension. That will fail in the way you describe.

Paul LeBeau
  • 97,474
  • 9
  • 154
  • 181
  • Thanks ... that makes sense. If I open the **.svgz** file in a vanilla text editor, it is indeed plain text ... no compression there. So I am guessing that the file on the server is **.svgz** and it gets uncompressed by the browser as the page loads. Then when I save the page, the now _uncompressed_ **.svg** file is saved with the **.svgz** extension. Then, on reopening of the local .html page, the incorrect extension name causes the browser to spit the dummy. – TaoRich Oct 06 '16 at 12:10
  • Just reporting the results from an additional test: Firefox exhibits the same behaviour ... so it's not just a Chrome issue. – TaoRich Oct 06 '16 at 12:11
  • One last question - for my understanding: Would this "break" all locally saved web pages where **.svgz** files are used ? Is this typical a typical behaviour problem using that image format ? – TaoRich Oct 06 '16 at 12:14
  • [ I did try to mark your answer as my accepted solution to my question but my rep is too low. Same situation with an up-vote. Manual thanks here :-) ] – TaoRich Oct 06 '16 at 12:15
  • Yes. What you suspected is also what I assumed was happening. Any site that precompresses it's SVG files would have this problem. I suspect that not many do. This is first time I have seen this problem reported here. – Paul LeBeau Oct 06 '16 at 12:32
  • Reported Chrome bug: https://bugs.chromium.org/p/chromium/issues/detail?id=654686 – Paul LeBeau Oct 11 '16 at 07:46