Convert a microsoft icon file to a (few) BMP(s) (or jpg's...) using Image::Magick;
#!/usr/bin/perl use Image::Magick; use strict; use warnings; my $file = 'coolplayer.ico'; my $base = $1 if $file =~ /^(.*)\.[a-z]{3,4}$/; my $outf = 'bmp'; my $image = Image::Magick->new(); my $ERR = $image->Read('coolplayer.ico'); die $ERR if $ERR and $ERR !~ /configuration file found/i; for( my $x = 0; $image->[$x]; $x++ ) { $ERR = $image->[$x]->Write("$base.$x.$outf"); warn "x=$x;$ERR" if $ERR and $ERR !~ /configuration file found/i; }

Replies are listed 'Best First'.
•Re: ICON TO BMP (using Image::Magick)
by merlyn (Sage) on Apr 02, 2003 at 21:47 UTC

      OTOH, your method only gets one of the several bitdepths/sizes embeded in an ico. (Probably either the largest one, or the one that happens to appear first in the file.)


      Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).