tags:

views:

85

answers:

3

I'm building a desktop application and I occasionally add images to the solution explorer. When I "Build" the application, I notice the .exe file increases in size. If I add an image that's 40kb, the .exe increases 40kb.

All in all, my application is currently 12mb, and I think it's a bit too much for people to download.

Is there a way for me to minimize the .exe size, in other words, add images to my application with minimal size impact?

+4  A: 

You can externalise the images, shipping them as separate files or having your app download them from a Web server. WPF is happy to use a HTTP or file system URL as the Source for an Image element.

But this just shifts the problem: your initial EXE is smaller, but now there's a bunch of other files to download as well. What it comes down to is: if you've got 12 MB of images, you've got 12 MB of images, and those 12 MB have got to get to the user's machine somehow!

If you're concerned about a 12 MB application size, you could try to make the files smaller -- lower resolution, different file format (e.g. JPG instead of BMP), etc. Or, if the user isn't going to need all of the files, you could have the app download them on demand (but note this could create delays, or errors if the user is offline).

On the other hand, by modern standards, 12 MB really isn't all that enormous for a game-type application (which is what I understand yours to be). So unless you're targeting a market where a lot of users are still on dial-up or other slow or poor connections, it may not be that big a deal.

itowlson
A: 

It really depends on your images but... if they're somewhat similar to each other you could zip them up and then expand at install or the first time the app runs. You could try zipping anyway just to see what happens. If you can reduce the images by 20% or more zipping might be worth it. (Or you could choose images that are similar on purpose to help out the zipping.)

Also, if your images are simple you could try the GIF format. It's very good at compressing images with lines and simpler fields of color (e.g. non-photographic images... more like Anime)

i also like itowlson's answer btw. +1

Paul Sasik
A: 

I just did a quick test of compile exe file sizes. If you add files to the solution explorer as a Resource, these images are compiled directly into the exe. However if you just add the file to the solution explorer and give the file a 'build action' of "Conten" and a 'copy to output directory' of "copy if newer" then the file isnt part of the exe, but is a secondary file alongside the exe.

This then means the image is availiable to your exe but is not part of it.

This might be what you are looking as it allows you to change the images used in the application easily [by just changing them in the solution folder]

Kurru