PMXBOT Log file Viewer

Help | Karma | Search:

#pil logs for Wednesday the 27th of November, 2013

(Back to #pil overview) (Back to channel listing) (Animate logs)
[16:50:45] <mikeybisbo> Hi guys: Is it possible to extract RGBA colours from an ICO file?
[16:51:06] <mikeybisbo> I'm using pillow and I know it has ico read support
[16:56:38] <mikeybisbo> I can't seem to get access to the alpha of some favicons
[17:13:24] <wiredfool1> mikeybisbo: depends on the ico
[17:13:37] <wiredfool1> there are lots of different formats, we read some of them
[17:13:57] <mikeybisbo> wiredfool1: I'm loading in one which has transparency, but the bands just say RGB
[17:14:18] <wiredfool1> is there a transparency entry?
[17:14:32] <wiredfool1> e.g. im.info['transparency']
[17:15:02] <mikeybisbo> no, that key doesn't exist
[17:15:08] <wiredfool1> ah.
[17:15:17] <mikeybisbo> hmm :-S
[17:15:47] <wiredfool1> I ask because there's a pull request related to that and pngs that hit yesterday
[17:15:58] <mikeybisbo> Ah okay
[17:16:17] <wiredfool1> do you know what ico format you're using?
[17:16:37] <mikeybisbo> Yeah I have 2 ice files I'm trying to get working, how can I find out the format of each file?
[17:17:54] <mikeybisbo> FYI it's http://mkgeeknight.co.uk/favicon.ico and http://d3i.com/favicon.ico that I'm playing with
[17:22:09] <wiredfool1> interesting.
[17:22:50] <mikeybisbo> if i load them and save them as a png straight away the transparent parts are black
[17:23:05] <wiredfool1> the first one has 9 different icons in it. only the last 3 of them have an alpha layer
[17:25:22] <mikeybisbo> hmm interesting - is there a way to specify which of the icons to load in pil?
[17:29:24] <mikeybisbo> I'd actually settle with being able to render the transparency onto white instead, and then I'd be able to use the RGB values
[17:31:40] <wiredfool1> so, the ico file support changed dramatically around 5/2013, doesn't look like bmp file info has changed lately.
[17:31:51] <wiredfool1> (icos are containers for bmp and png files)
[17:32:41] <wiredfool1> we support the first 3 bmp formats in this table: https://en.wikipedia.org/wiki/BMP_file_format#DIB_header_.28bitmap_information_header.29
[17:33:01] <wiredfool1> which doesn't look like it includes alpha channel support
[17:36:01] <wiredfool1> Pillow is only picking up three of the icons in the first one
[17:37:26] <wiredfool1> what version of pil/pillow are you using?
[17:39:07] <wiredfool1> https://gist.github.com/wiredfool/7679863
[17:39:26] <mikeybisbo> I'm using Pillow 2.2.1
[17:40:17] <wiredfool1> I can get the alpha channel out of each of them usign the code from the gist
[17:40:27] <mikeybisbo> oh interesting, thanks for that gist
[17:40:27] <wiredfool1> that's what the split/show does
[17:41:23] <wiredfool1> I'm checking 2.2.1 now, since I was on one of the png transparecny branches
[17:41:40] <mikeybisbo> okay great, thank you
[17:42:43] <wiredfool1> it does look like that works in 2.2.1
[17:49:16] <mikeybisbo> Right, okay I'm getting somewhere :-) Firstly I realised my experimenting was on a different venv (and older oil) than my project!! So I've read in the ICO files and they're both RGBA :-)
[17:54:26] <wiredfool1> cool
[18:04:14] <mikeybisbo> wiredfool1: awesome, this is working great! https://gist.github.com/mwaterfall/d121b2ce299248a6466f
[18:05:14] <mikeybisbo> wiredfool1: I'm splitting the colours and detecting the most prominent one (avoiding B&W and colours that are too light to go against white).
[18:11:14] <wiredfool1> cool
[18:11:31] <mikeybisbo> wiredfool1: thanks so much for your help, much appreciated!
[18:11:45] <wiredfool1> sure thing