问题
I just spent an infuriating day trying to make a gif out of a series of jpg files in R. I installed ImageMagick to run the following code:
system("convert -delay 40 *.png example_4.gif")
but I get the following error message:
Warning message:
running command 'convert -delay 40 *.png example_4.gif' had status 4
which looks like a path error. Now I've looked for convert in the Imagemagick download and can't see it anywhere. Does anyone know where it is?
Alternately, is there another easier method of making a gif from a series of jpegs in R that isn't ridiculously long?
Thanks
回答1:
Three options:
- Consider using the magick R package instead of using
system()
. - Change your script from
convert ...
tomagick convert ...
. Re-install imagemagick, and enable the "Install legacy utilities (e.g. convert)" option.
This change has been around since 7.0.1 (now up to 7.0.7), and is discussed in their porting guide, specifically in the section entitled "Command Changes".
Philosophically, I prefer to not install the legacy utilities, mostly because it can cause some confusion with command names. For instance, the non-ImageMagick convert.exe
in windows tries to convert a filesystem ... probably not what you want to accidentally trigger (there is a very low chance that you could get the arguments right to actually make a change, but it's still not 0). The order of directories in your PATH
will dictate which you are calling.
EDITs:
From comments, it seems like the difference between "static" and "dll" installers might disable the option to install legacy utilities such as
convert.exe
. So you can either switch to the "dll" to get the legacy option, or you are restricted to options 1 (magick
R package) and 2 ("magick convert ..."
).From further comments (thanks to fmw42 and MarkSetchell), it is clear that the old
convert.exe
and the current legacy mode ofmagick.exe convert
are not the same as the currently recommendedmagick.exe
(without "convert"); the first two are legacy and compatibility modes, but they do not accept all arguments currently supported bymagick
-alone. So the use of"convert"
anywhere in the command should indicate use of v6, not the current v7. This answer is then merely a patch for continued use of the v6 mechanisms; one could argue a better solution would be to usemagick.exe
's v7 interface, completely removing the "convert" legacy mode.
来源:https://stackoverflow.com/questions/46059436/where-is-convert-in-imagemagick