Take the 2-minute tour ×
Graphic Design Stack Exchange is a question and answer site for professional graphic designers and non-designers trying to do their own graphic design. It's 100% free, no registration required.

I have a picture of a map of Europe with proper borders. I need to color each country in different shades of color according to certain properties of the country. This is trivial manually in PS or GIMP with the Fill tool. However, I need to do it many times over, with different colors for different use cases, so I would want to automate it. I'm comfortable programming, but have zero experience in scripting graphical tools.

Any hints on what the best way to do it would be? Imagemagick, Gimp? If at all possible, I would prefer free tools (since it's a one off thing, i dont want to invest into PS).

share|improve this question
    
I think the answer may depend somewhat on whether you want to output simple low res raster images, high res raster images, or vector art. –  e100 May 18 '12 at 17:16
add comment

2 Answers

up vote 1 down vote accepted

If I were to do this "from the ground up," I might make each country shape its own layer black only, with the layers named uniquely, and apply a layer effect "color overlay." To achieve the desired color, and a stroke to define the outline. If there is more detail to the map, and you only want to alter the background color, you can overlay other items with a different layer.

Flood fill can be tricky depending on non-contiguous areas and anti-aliasing of the item, so the layer effect would probably give you an easier time.

To view all countries, you toggle all layers visible. To programmatically change a color, you can now reference the layer by its unique ID, and then alter the color overlay property.

The specifics of how to do this will depend on your need and the program you use. I know that both GIMP and PS are scriptable (and AFAIK, support color overlay and stroke).

With Photoshop, you can use vbscript and then have access to the OS file system (I don't think javascript allows this?). The benefit of this is that you could create a data file with the country's layer name and color info (etc) and possibly calculate different things on the fly. It also supports variables and data files IIRC (the limits of which I am not familiar).

Knowing open source, GIMP probably gives you deeper access to the backend for scripting.

share|improve this answer
1  
Great suggestion. Alternatively, if you can get a vector map, using SVG to colour may be good as well. SVG is pretty easy to edit programatically. –  Marc Edwards May 18 '12 at 15:39
    
true, svg looks to be XML, so scripting might be as easy as find+replace or you could use an xml library for better control. –  horatio May 18 '12 at 16:54
add comment

I'd be tempted to write my own code in my favourite language using the ImageMagick library.

You could create a lookup table with names of countries linked to a point (or points if there are islands) within their borders, then you can pass the name of the country to flood fill it.

Handling anti-aliased edges might be difficult though.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.