libgd-gis

map.image — Accessing the Rendered Image

After rendering a map, libgd-gis exposes the underlying GD::Image instance through map.image. This allows you to post-process the rendered map using the full power of ruby-libgd.

This design cleanly separates:


Basic usage

map.render
img = map.image

img is a GD::Image object and supports all ruby-libgd operations.


What you can do with map.image

Once you have access to the image, you can:


Example: adding a label after render

img = map.image

font = "../fonts/DejaVuSans-Bold.ttf"

img.filled_rectangle(24, 24, 264, 88, [0, 0, 0])

img.text(
  "TOKYO",
  x: 48,
  y: 68,
  size: 32,
  color: [255, 255, 255],
  font: font
)

img.save("tokyo.png")

Why post-render manipulation matters


Relationship with overlays

map.image complements overlay methods such as:

Use overlays for geographic data, and map.image for pure image manipulation.


Summary

vintage