To be more specific, let me explain my end result goal or more of what I would LIKE to have someday and then you can tell me if its even feasible and if not possibly an alternative method.

I really would like to have a tool like smush.it it is a website Yahoo runs that optimizes images, it is currently one of the best out there. There FAQ page say they use all these programs to do it...

ImageMagick: to identify the image type and to convert GIF files to PNG files.
pngcrush: to strip unneeded chunks from PNGs. We are also experimenting with other PNG reduction tools such as pngout, optipng, pngrewrite. Hopefully these tools will provide improved optimization of PNG files.
jpegtran: to strip all metadata from JPEGs (currently disabled) and try progressive JPEGs. gifsicle: to optimize GIF animations by stripping repeating pixels in different frames. More information about the smushing process is available at the Optimize Images section of Best Practices for High Performance Web pages.

So basically you upload an image and it determines it's file type and runs it through the appropriate programs or programs and returns an optimized image and tell the original size and thew new size of the image.

If you search across StackOverflow you will see that many people are searching for an all in one program that can do this, mainly from the command line for Build scripts to use.

Now I am curious, is it possible to make a program that could be like 1 package that would include all these other programs into it, so on Windows it would be like 1 exe file or even a jar file would probably work as I know Yahoo has a jar file for Javascript compression that my Build script can use.

In my searches I have found 1 project that is similar but I am not sure if it is really what I am after, it is http://trimage.org/ it uses uses OptiPNG, PNGCrush, AdvPNG, JPEGOptim. My problem with this 1 is first of all they do not release it for Windows but they say it's may be able to work on Windows, but mainly I saw the source code and it is just a bunch of Python scripts, also the programs it uses, all have to be installed separately.

My goal is to be able to not have to install 4-5 separate programs but to have them as 1

Please tell me if this is just a dream or something that's id possible, I only have a PHP background so hardly the knowledge for a project like this

  • this is pretty much why perl exists – Ryathal Dec 19 '11 at 14:05

Of course this is technically possible. In fact, most software out there does something similar, so I will not further comment on the technical aspects here. If you do have problems with that you may want to ask a more specific question here or on stackoverflow.com.

However, there are some other points you may want to consider:

  • Usually, you do not bundle the programs as .exe files, but rather include library versions of these. For example, ImageMagick itself is already bundling several graphic libraries (optionally even), like libpng or libjpeg. Another example is transcode, which does similar things with movies instead of images. First, this approach allows you direct API access to the other libraries, and second, you do not have to ship several .exe files and possibly confuse your users as to which one they should execute.

  • The main problem from a non-technical perspective is the redistribution problem involved, when you take someone else's project and simply make it part of your program. Not all existing programs allow you to do this. You have to be very careful about the licences these programs have been published with. A solution I sometimes come across for this is to require users to actually install the 3rd party software themselves and the program checks for its presence dynamically when being run. As this is not what you seem to want though, I can only urge you again to be careful about the licencing.


What you seem to want to do is the following:

  • write one program part that just takes a generic image
  • figure out the images file type
  • hand the image over to a specific module reponsible for that image type
  • choose one of the following
    • apply all the optimizations you have
    • add another chooser that hands over the image to a submodule

If you're new to programming, have a look at the "decorator pattern". It'll help you handing over the same image to multiple optimizers in a row.


Assuming you have access to all source code, it is probably possible, but not very useful.

First, you should be sure that all the programs (supposedly in C) do not have any name clashes, so no global name (except main) appears in more than one program.

Then you could link all the "quasi-programs" together.

Back in the 1987? on SunOS3.5, shared libraries didn't exist, so Sun shipped a single executable which basically tested the first argument of the program (which is the program name), and executed the appropriate thing, using something similar to (assuming three programs foo, bar, and gee with their global names prefixed by foo_, bar_, gee_ respectively)

 /* the three main-s */
 extern int foo_main(int, char**);
 extern int bar_main(int, char**);
 extern int gee_main(int, char**);

 int main (int argc, char**argv)
    if (!strcmp(argv[0], "foo"))
       return foo_main (argc, argv);
    else if (!strcmp(argv[0], "bar"))
       return bar_main (argc, argv);
    else if (!strcmp(argv[0], "gee"))
       return gee_main (argc, argv);
       fprintf (stderr, 
               "expecting foo, bar, or gee as program, but got %s\n",
    return 3;

PS. I would have asked that on StackOverflow.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.