Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Merge multiple BMP images into ICO files

by jimbojones (Friar)
on Mar 22, 2007 at 12:58 UTC ( #606007=perlquestion: print w/replies, xml ) Need Help??
jimbojones has asked for the wisdom of the Perl Monks concerning the following question:


I have been exploring ways to read in a number Windows .bmp image files and merge them into a single .ico file.

So far I've looked at Win32::Exe, which seems to read .ico files and break them down into constituent icons, but seems to lack a method for creating .ico files. It was hard for me to tell because the doc is a bit lacking and my Perl-fu is below the level of this code.

I also looked into Image::BMP which reads .bmp files but doesn't output them again.

I realise this is all a bit vague. If anyone has any pointers or starting places, I'd be grateful. Also, I'd prefer not to do this through a system call to a graphics tool because even though these are windows files, I need to be able to run the process on a non-window OS.

Thanks in advance, J

Replies are listed 'Best First'.
Re: Merge multiple BMP images into ICO files
by Corion (Pope) on Mar 22, 2007 at 13:00 UTC

      Thanks for the suggestion. Imager looked quite promising, but it seems to do its .ico processing using a XS backend .dll that I won't be able to use on other OSs.

      Unfortunately I think I need a pure-Perl solution.

      - j
        I think you're incorrect about needing a .dll file. I've used imager on a few linux boxes, and though I've never needed to do much with .ico files, I've been more than pleased with having chosen that package to work with.


Re: Merge multiple BMP images into ICO files
by MonkE (Hermit) on Mar 22, 2007 at 14:02 UTC
    Have you looked at Image::Magick? It is capable of creating ICO files, and the Image Magick library is available on various platforms. I'm not sure if it can create multiple-icon icon files or not, but it should be worth looking into.
Re: Merge multiple BMP images into ICO files
by leocharre (Priest) on Mar 22, 2007 at 14:04 UTC

    imagemagick, mogrify, convert ? It's really smelling like 'convert' here.

    They have ICO listed as a supported format.


      Yes, ImageMagick would do what I want, but I don't want to have to build bindings for ImageMagick across multiple OSs.

      This may be an X-Y problem. The issue is that this is for an in-house build for an Eclipse Rich Client Platform Application. For Eclipse RCP, you can build all OS applications on one system, because the "executable" is really a bundled launcher. So the Eclipse folks give you the executable for all OSs in the Eclipse bundle, and you copy it to the name of your application. The executable then loads your Rich Client Application java code . So concievably, you can build Win32, linux, sparc, hp-ux Rich Client applications all from a Mac OS X machine (for example).

      The trick is that the windows executable has the icon embedded in it, and I'm trying to figure out how to change the icon in the executable. Win32::Exe can change the icon of a windows executable given an .ico file, and seems to be pure Perl. However, I have a set of .bmp files that need to be converted to .ico, then I can embed them.

      Eventually we may distribute this setup to other people/systems and the requirement to have/install/build ImageMagick side task seems a bit like overkill. But then again, I can't spend days looking into it, so ImageMagick might have to do.

      Thanks for the input. - J

        There's this book I'm reading.. called why things bite back. It has some good examples of when the solutions we create for everyday problems, bring new problems.

        It may be slightly simpler to skip the "build perl bindings for ImageMagick for each platform" step, and use the command-line magick tools. While it's admirable to try to integrate the two into a monolithic tool, there comes a point when it's valuable to rely on system() and ship a small private bundle of dedicated tools.

        For example, many Mac OS X tools are starting to embed more of these tiny command-line tools into their .app packaging, unbeknownst to the user. The fact that for Darwin, an application IS a subdirectory just helps that process along, but there's no reason you can't do that with application bundles on other platforms.

        [ e d @ h a l l e y . c c ]

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://606007]
Approved by marto
[Perl300]: I found from Super Search, Net::SMTPS or Net::SMTP, MIME::Lite, Email as options
[1nickt]: Perl300 Try Email::Stuffer
[1nickt]: Or for a little more control, Email::Sender:: Simple
[Perl300]: any suggestion on which one might be secure and simplest. I am not doing anything complex, just check some conditions from DB tables and send email to myself (same domain) if conditions are met
[1nickt]: read the doc of the suggestions I just gave
[1nickt]: A lot depends on whether you are sending mail from your local box or using a remote server
[hippo]: Secure in what sense?
[Perl300]: I am sending from remote server
[1nickt]: Then see Email::Sender:: Transport::SMTP
[Perl300]: secure in sense it should not cause any security concerns, create some loop holes.... I don't know much about it but don't want to cause any problem for security guys here

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (11)
As of 2017-10-17 15:55 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (233 votes). Check out past polls.