On 15.08.2011, at 23:15, Igor Podolskiy wrote:
>> No, it stops as soon as it sees the second color (for getcolors(1))...
> ummm, my gut says there isn't a second color in a single-color image :)
Well, that's true for actual single color images, but not for regular tiles.
>> and Mapniks tostring() and PILs fromstring() are just a memory copy. So this
>> will also be fast. Of course, you need PIL as a dependency.
> Don't know about Mapnik, but since I had the PIL sources open anyway, I
> looked it up. PILs fromstring() is a bit more involved than a memory copy. It
> actually has a cyclomatic complexity of three. Of course, it most probably
> _is_ quite fast so that you can't tell it from a memory copy for most
> practical purposes.
It's 28x faster on my system for a transparent tile.
`Image.frombuffer('RGBA', (256, 256), img, 'raw').getcolors(1)` takes 0.18ms
and
`is_tranparent(img)` 5.2ms
Regards,
Oliver
--
Oliver Tonnhofer | Omniscale GmbH & Co KG | http://omniscale.de
http://mapproxy.org | https://bitbucket.org/olt | @oltonn
_______________________________________________
dev mailing list
[email protected]
http://lists.openstreetmap.org/listinfo/dev