2012-01-12

Printing Google / Sogou maps

Have you had this experience? You've centered and zoomed the map of an interesting area on Google Maps, or a similar site (e.g., maps.sogou.com) and wanted to print it. Some map sites actually have a "print" button, or you can just use the "print screen" / "screen capture" button of your operating system's window manager to save the image into a PNG file to print it later (directly, or after including it and the caption text into an HTML / PDF / LaTeX file). But, whatever you do, chances are that the printed image will be almost un-readable: Google, Sogou, and other map sites optimize the image for on-screen viewing, and printing is just an afterthought.

There is, however, an easy way to improve the legibility of the map image. The idea is, an image is hard to read because there is not much contrast to it: both the brightest pixels (the background) and the darkest pixels (text and lines) are merely shades of grey (or, generally, some intermediate RGB colors), rather than good old printable black and white.

So the solution for improving the printable quality is, basically, as follows: figure what color you want to convert into black, what color you want to convert into white, and linearly transform all colors in between.

There are of course plenty of image manipulation tools on the market. The one I happen to use is ImageMagick, and sure enough, it has a command for it.

To find the colors to be made into black and white, you probably can zoom in on your screenshot image in some image editing program, and take a look at what the RGB values for the darkest pixels (parts of text, or lines showing roads etc) are, and what the RGB values for the brightest pixels (the not-quite-white background). In my case, I did it with cropping out a small section of the image with "convert -crop", and then querying the range of colors with "identify -verbose". Having chosen the colors this way, all you need to do is a single command:

convert original-map.png -level-colors 'rgb(144,144,10),rgb(241,238,232)' printable-map.png

Enjoy!

Before After

2012-01-06

I know how to say "to loiter" in Chinese

I used to joke that the English verb "to loiter", as in the "No loitering" sign, is one of the words particularly hard to translate to other languages. Well, thanks to David Feng's useful post with the do's and don'ts of picture-taking in China's railway and subway stations, I now know that at least in Chinese they do have a word for it: 久留 (jiuliu), which means more or less what its components indicate.