[Pythonmac-SIG] Question about Pil and icns...

Bob Ippolito bob at redivi.com
Thu Dec 23 01:49:45 CET 2004


On Dec 22, 2004, at 7:45 PM, whamoo wrote:

>
> On 23/dic/04, at 01:29, Bob Ippolito wrote:
>
>>
>> On Dec 22, 2004, at 7:09 PM, whamoo wrote:
>>
>>> I've read that new beta of the Pil now add support for icns file 
>>> format, nice, but in the code of the plugin i read that there is 
>>> only the read support, so, i cannot convert icns in other format and 
>>> vice-versa? And if i load icns, work on it, then i cannot save.....
>>> Can someone tell me something about it? Someone have tried?
>>
>> That is correct, this is read-only support.  You may not save icns 
>> files with the code in PIL.
>
> But starting by reading a icns, i can save a png or jpg?

Yes, of course.  Image.open('myapp.icns').save('myapp.png') will 
probably Just Work.

>> You could of course do it the native way, using Mac APIs, or just by 
>> dragging images into Icon Composer.
>
> There is a fast way to produce icns starting from a 128x128 image 
> (format Png, jpg doesn't matter)?
> What Mac Api i must use? I've search documentation, but found about 
> nothing (maybe I'm not able to search), i want write a python program 
> to convert images in icns in a background fast way, i can't drop 1000 
> image con icon composer =)

The easiest way would probably be to use IconFamily from PyObjC 
<http://homepage.mac.com/troy_stephens/software/objects/IconFamily/>.  
Carbon is always a pain in the ass, but the Icon Services functions may 
be wrapped (not sure?).  NSImage will load pngs and jpegs quickly and 
easily.

-bob



More information about the Pythonmac-SIG mailing list