For next major ImageMagick version, please consider folding the 8 major command line binaries into one like this:
im compare ...
im composite ...
im conjure ...
im convert ...
im identify ...
im mogrify ...
im montage ...
im stream ...
This would make so much sense: Why should convert/mogrify be separate binaries internally 99% identical? And to new users: Why is the software called ImageMagick but not the binary?
For the statically linked versions, this would reduce space dramatically from about 8×15 MB to 1×15 MB! Almost all the code is in the libraries which all link, very little is specific to each.
Imagine that one killer statically linked portable im executable. Just one file could do almost everything on its own without being significantly larger than either of the current 8.
To not immediately break all existing scripts/wrappers/APIs, consider bridging the gap with 8 symlinks/shell scripts/batch files with the old names pointing to the new. But do state those are being deprecated. Also consider making the binaries filename-sensitive so you could e.g. get the new im to behave like the old convert simply by renaming it. Then a user could even just copy it into 8 copies or 7 symlinks and 1 real file for restoring the old behavior/waste of space.
This would also solve the long-standing problem for Windows versions that IM's convert.exe conflicts with a system command. As a poor workaround IM's installer sets the path to the exes before the system root; bad practice, slows system down. See also this post.
This of mirrors what the fork GraphicsMagick did. But that one doesn't come statically linked so their benefit is less.
I wouldn't suggest folding the 4 binaries IMDisplay, dcraw, ffmpeg or hp2xx into this; they are different animals.
Consolidate executables for simplicity, size and nonconflict w/ convert.exe
-
- Posts: 4
- Joined: 2016-03-28T01:23:10-07:00
- Authentication code: 1151
Re: Consolidate executables for simplicity, size and nonconflict w/ convert.exe
There is little overhead associated with the various ImageMagick utilities for the recommended dynamic release of ImageMagick (each utility is about 10K bytes). ImageMagick 7, removes the 'convert' command and replaces it with 'magick', resolving the Windows 'convert' utility conflict. We're not overly concerned about the modest additional resources consumed by the static release. For those that need to reduce the footprint of the static release, you can replace all the utilities with one simply by calling MagickCommandGenesis(), one call for each utility (i.e. ConvertImageCommand, CompositeImageCommand, etc.). Post your work here so others can benefit from your effort.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Consolidate executables for simplicity, size and nonconflict w/ convert.exe
That's a nice little challenge. Here's my offering, that I call snibim.c:magick wrote:... you can replace all the utilities with one simply by ...
Code: Select all
#ifndef IMV6OR7
#define IMV6OR7 6
#endif
#if IMV6OR7==6
#include <wand/MagickWand.h>
#else
#include <MagickWand/MagickWand.h>
#endif
static void usage (char **argv)
{
printf ("Usage: %s {im_command} {im_options}\n\n", argv[0]);
printf ("{im_command} is one of "
"Convert, Identify, Mogrify, Composite, Compare, "
"Conjure, Stream, Import, Display, or Animate.\n\n");
printf ("{im_options} is any options for that command.\n");
exit(1);
}
static MagickCommand CommandOfStr (char * s, MagickBooleanType * isValid)
{
typedef struct {
char * string;
MagickCommand cmd;
} strCmdT;
strCmdT strCmds[] = {
{"convert", ConvertImageCommand},
{"identify", IdentifyImageCommand},
{"mogrify", MogrifyImageCommand},
{"composite", CompositeImageCommand},
#if IMV6OR7==6
{"compare", CompareImageCommand},
#else
{"compare", CompareImagesCommand},
#endif
{"conjure", ConjureImageCommand},
{"stream", StreamImageCommand},
{"import", ImportImageCommand},
{"display", DisplayImageCommand},
{"animate", AnimateImageCommand},
};
int nCmds = sizeof (strCmds) / sizeof (strCmdT);
int i;
for (i = 0; i < nCmds; i++) {
if (LocaleCompare (s, strCmds[i].string)==0) {
*isValid = MagickTrue;
return strCmds[i].cmd;
}
}
*isValid = MagickFalse;
return strCmds[0].cmd;
}
int main (int argc, char **argv)
{
MagickBooleanType
status = MagickFalse;
if (argc < 3) {
usage (argv);
}
ExceptionInfo * exception = AcquireExceptionInfo ();
ImageInfo * image_info = AcquireImageInfo ();
MagickBooleanType isValid;
MagickCommand cmd = CommandOfStr (argv[1], &isValid);
if (isValid) {
status = MagickCommandGenesis(image_info, cmd, argc-1, &argv[1], NULL, exception);
} else {
usage (argv);
}
image_info = DestroyImageInfo (image_info);
exception = DestroyExceptionInfo (exception);
return (status==MagickFalse) ? 1 : 0;
}
With that short program, I no longer need convert.exe, identify.exe and all the rest.
Run it like this:
Code: Select all
snibim convert rose: r.png
snibim identify rose:
snibim compare -metric rose: rose: NULL:
snibgo's IM pages: im.snibgo.com
Re: Consolidate executables for simplicity, size and nonconflict w/ convert.exe
I made the same suggestion in December 2002; my patch (similar in concept to snibgo's) was accepted by GM but not by IM. It didn't affect CPU or memory usage, much, but it does reduce the size of downloaded executables by 80 or 90 percent.
Re: Consolidate executables for simplicity, size and nonconflict w/ convert.exe
When ImageMagick 7 is released, all ImageMagick commands will run from the 'magick' utility. For convenience, symbolic links will be installed for the convert, composite, montage, etc.