HTML-Imagemap handling for the Gimp

I wrote a little Script-Fu to add a minimal support for Client-Side Imagemaps to the Gimp. The handling is simple:

First select a region. The current version supports rectangular and circular selections. So it is useful to use the appropriate selection-tools. Then do a "<Image>/Select/Save as Hotspot". The Script will prompt for an URL, an ALT-Text and for the type of the Hotspot (Rectangle/Circle). If "Keep Selecion" is disabled the selected region after running the script is exactly the marked hotspot. Otherwise the previous selection will be restored.

the first hotspot-dialog

If you defined all the Hotspots you can write the Imagemap to disk via "<Image>/File/Save Hotspots". This script prompts for a Name of the Imagemap and the Filename. If the Filename is empty ("" in the Dialog) the Map will be written to Stdout. So it is easy to include in a HTML-File via cut'n'paste.

the second hotspot-dialog

Some more Details: When adding a new selection the script will add a new channel to the image. This contains the circle/rectangle (In Fact only the bounding-coordinates are relevant). The save-function converts this channel back to a selection, asks for the selection-bounds and converts them to coordinates for the Hotspot. The additional information (URL/ALT-Text/Type of Hotspot) is stored in the Channel name. The information is stored in a very specific way, so that it is easy to check, if it is really a Hotspot-Channel or just a channel crated by the artist. A Channel-name

Hotspot (Circle): http://www.gimp.org{***}The Gimp Homepage
marks a circular hotspot, pointing to "http://www.gimp.org" with the ALT-Text "The Gimp Homepage". So you can create Hotspot-channels by hand, but if there is an typo in the beginning of if there is no "{***}" in it, the save-function would not recognize it.

Since the coordinates are stored in additional channels it is possible to rescale an images, and the Hotspots will be correct too - with the exception, that circular hotspots will shrink, when scaling unconstrained. This is necessary, because HTML doesn't handle elliptical selections.

As long as you just scale constrained, the hotspots will keep intact. It is possible to make them visible by making the appropriate channel visible. Also deleting the associated channel will delete the associated hotspot. It is not planned, to add support for polygonal hotspots. It is nearly impossible to get the coordinates from a polygonal selection. I don't want to implement a semi-intelligent trace-routine - especially not in Scheme. So you'll have to live with it :-)

Here is an example: An image with imagemap, and the Layers&Channels-Dialog. The XCF.gz is available here.

Demo Imagemap

Image of the Dialog

I hope, the script is handy. Get it at http://www.home.unix-ag.org/simon/gimp/hotspots.scm.

Simons Homepage Unix-AG Homepage Gimp-Homepage

 
[Home]
[Gimp]
-- [Pagecurl]
-- [Quant]
-- [Globen]
[Pingu]
[Musik]
[Links]

Zuletzt geändert am 26.08.98    © 2000-2003 by Simon Budig