Snippet List
PIL IcoImagePlugin is twelve year old and it can't handle recent Windows ICO files. Here is a function that handles all ICO versions and preserve transparency.
Usage:
# Load biggest icon from file
image = load_icon('icon.ico')
# Save third icon as PNG
load_icon('icon.ico', 2).save('icon.png')
Yet another class to simplify field choices creation. Keeps order, allows i18n.
Before:
ONLINE = 0
OFFLINE = 1
STATES = (
(ONLINE, _('online')),
(OFFLINE, _('offline'))
)
state = models.IntegerField(choices=STATES, default=OFFLINE)
After:
STATES = Choices(
('ONLINE', _('online')),
('OFFLINE', _('offline'))
)
state = models.IntegerField(choices=STATES, default=STATES.OFFLINE)
dc has posted 2 snippets.