generate_tiles.py - image class

View: New views
2 Messages — Rating Filter:   Alert me  

generate_tiles.py - image class

by Warren Vick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

In the generate_tiles.py script which generates map tiles using Mapnik, what is the image class used? I don't know if this is something internal to Python or an external class imported by Mapnik. I'd like to be able to add a black 1-pixel frame around each map before saving but don't know if the image class has any pixel/line writing methods.

Regards,
Warren
_______________________________________________
Mapnik-users mailing list
Mapnik-users@...
https://lists.berlios.de/mailman/listinfo/mapnik-users

Re: generate_tiles.py - image class

by Dane Springmeyer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Warren,

Yes, generate_tiles.py uses the 'Image' class from Mapnik, which  
supports a fairly limited set of functions:

http://svn.mapnik.org/trunk/docs/api_docs/python/mapnik._mapnik.Image-class.html

However we can add more that are useful. I think of PIL.Image as a  
very similar class that we can borrow functionality from if needed,  
and perhaps you could get what you need working using PIL natively  
right now which would help assess the benefit of eventually folding  
more methods into mapnik.Image.

Here is how to turn a mapnik.Image into a PIL.Image:

 >>> img = mapnik.Image(w, h)
 >> mapnik.render(map, img)
 >> pil_img = PIL.Image.fromstring('RGBA', (w, h), img.tostring())

Dane

On Sep 6, 2009, at 12:56 AM, Warren Vick wrote:

> In the generate_tiles.py script which generates map tiles using  
> Mapnik, what is the image class used? I don't know if this is  
> something internal to Python or an external class imported by  
> Mapnik. I'd like to be able to add a black 1-pixel frame around each  
> map before saving but don't know if the image class has any pixel/
> line writing methods.
>
> Regards,
> Warren
> _______________________________________________
> Mapnik-users mailing list
> Mapnik-users@...
> https://lists.berlios.de/mailman/listinfo/mapnik-users

_______________________________________________
Mapnik-users mailing list
Mapnik-users@...
https://lists.berlios.de/mailman/listinfo/mapnik-users