-1

I'm looking for a way to compress the tiles from a Google Map (which I've already done) and then somehow replace the old tiles with the compressed tiles. This is how a tile looks in the code, for example:<img src="https://mts1.googleapis.com/vt?pb=!1m4!1m3!1i13!2i2475!3i3029!2m3!1e0!2sm!3i293208756!3m9!2sen-US!3sUS!5e18!12m1!1e47!12m3!1e37!2m1!1ssmartmaps!4e0!5m1!5f2" draggable="false" style="width: 256px; height: 256px; -webkit-user-select: none; border: 0px; padding: 0px; margin: 0px;">

The reason I want to do this is because Google PageSpeed Insights keeps complaining:

Should Fix: Optimize images Properly formatting and compressing images can save many bytes of data. Optimize the following images to reduce their size by 245.2KiB (17% reduction).

(And all of the images it wants me to optimize are from the map.) I haven't been able to find anything googling around, so I don't even know if it's possible to do what I'm asking. Any ideas?

Xar
  • 41
  • 1
  • 1
  • 5

1 Answers1

0

The first idea I came across at first glance is to remove metadata. I've checked the image you put in the example and has no metadata at all. So the next idea was that you might be able to change the PNG file format to JPG which may reduce the file size considerably. Here's a post that might help you, but you will have to tweak the script in order to match your needs:

How to convert a image from PNG to JPEG using javascript?

Actually, you may be able to base64 encode the image into canvas, then just replace the original one with the encoded one? you'll be using computing power from the client instead of requesting the image.

Community
  • 1
  • 1
Diego Sagrera
  • 263
  • 5
  • 11
  • I have no idea what you mean about base64 encoding the image lol...but I'm going to try your other suggestion, thanks. – Xar Feb 27 '15 at 22:45
  • Encoding an image into base64 allows you to "print" the actual image without having to make a new request to the server to look for the image. It converts the image into a string. Here's an example: `code` ' ?>`code` – Diego Sagrera Mar 04 '16 at 23:19