转换和迁移:在现代版本的ImageMagick中使用它们的正确方法 [英] convert and mogrify: The correct way to use them in modern versions of ImageMagick

查看:111
本文介绍了转换和迁移:在现代版本的ImageMagick中使用它们的正确方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要使用旧版本的ImageMagick创建图像缩略图,可以通过以下方式进行:

To create an image thumbnail using an older version of ImageMagick, it was possible in the following ways:

(为帮助进一步引用,对示例进行了编号.)

1. convert.exe image.jpg -thumbnail 100x100 ./converted/converted_image.jpg
2. mogrify.exe -thumbnail 100x100 -path ./converted image.png

现在我有ImageMagick 7(昨天才下载),在安装过程中,我有意关闭了安装旧版实用程序(例如convert.exe)" 复选框.也就是说,我的ImageMagick目录中只有一个实用程序:magick.exe.

Now I have ImageMagick 7 (downloaded just yesterday), and during installation I intentionally turned "Install legacy utilities (e.g. convert.exe)" checkbox off. That is, I have only one utility in my ImageMagick directory: magick.exe.

我试图了解根据现代ImageMagick版本执行上述操作的正确方法和面向未来的方法.

I'm trying to understand what is the correct and future-proof way to perform above-mentioned operations according to modern ImageMagick versions.

来自 https://imagemagick.org/script/porting.php#cli :

animatecomparecompositeconjureconvertdisplayidentifyimportmogrifymontagestream

animate, compare, composite, conjure, convert, display, identify, import, mogrify, montage, stream

为减少命令行实用程序的占用空间,这些实用程序是指向magick实用程序的符号链接.您还可以从magick实用程序调用它们,例如,使用magick convert logo: logo.png调用magick实用程序.

To reduce the footprint of the command-line utilities, these utilities are symbolic links to the magick utility. You can also invoke them from the magick utility, for example, use magick convert logo: logo.png to invoke the magick utility.

在同一来源中:

通过由magick实用程序激活的IMv7解析器,设置将依次应用于内存中的每个图像(如果有).一个选项:仅全局应用一次.直接使用其他实用程序,或作为magick CLI的参数(例如magick convert)使用旧式解析器.

With the IMv7 parser, activated by the magick utility, settings are applied to each image in memory in turn (if any). While an option: only need to be applied once globally. Using the other utilities directly, or as an argument to the magick CLI (e.g. magick convert) utilizes the legacy parser.

嗯...

作品:

3. magick.exe convert image.jpg -thumbnail 100x100 ./converted/converted_image.jpg
4. magick.exe mogrify -thumbnail 100x100 -path ./converted image.png

仍然有效(与magick.exe convert相同):

5. magick.exe image.jpg -thumbnail 100x100 ./converted/converted_image.jpg

但是,以下一项不起作用(预期:应该与magick.exe mogrify相同):

However, the following one doesn't work (expected: should work the same way as magick.exe mogrify):

6. magick.exe -thumbnail 100x100 -path ./converted image.png

我的问题是:convertmogrify应该使用哪种语法? 3和4,或4和5,还是其他?

My question is: Which syntax should I use for convert and for mogrify? 3 and 4, or 4 and 5, or something different?

推荐答案

AFAIK,我很高兴添加任何建议的更正,它的工作原理如下.

AFAIK, and I am happy to add any corrections suggested, it works like this.

第一个想法是,如果可能的话,您应该使用版本7,所有旧的v6命令除外 convert都应以magick作为前缀.这意味着您应该使用这些

The first idea is that you should use version 7 if possible and all the old v6 commands, WITH THE EXCEPTION OF convert should be prefixed with magick. That means you should use these

magick ...                # in place of `convert`
magick identify ...       # in place of `identify`
magick mogrify ...        # in place of `mogrify`
magick compare ...        # in place of `compare`
magick compose ...        # in place of `compose`

如果使用magick convert,您将获得旧的v6行为,因此您要避免这种情况!

If you use magick convert you will get old v6 behaviour, so you want to avoid that!

此外,v7对订购更为挑剔.您必须之前指定要进行处理的图像.这意味着旧的v6命令如下:

Furthermore, v7 is more picky about the ordering. You must specify the image you want something done to before doing it. That means old v6 commands like:

convert -trim -resize 80% input.jpg output.jpg

现在必须成为:

magick input.jpg -trim -resize 80% output.jpg     # magick INPUT operations OUTPUT


因此,专门查看您的编号示例:


So, looking specifically at your numbered examples:

  1. 应成为:

  1. Should become:

magick image.jpg -thumbnail 100x100 ./converted/converted_image.jpg

应成为:

magick mogrify -thumbnail 100x100 -path ./converted image.png

会调用旧的v6行为,因为您使用的是magick convert而不是普通的magick,因此应避免使用

invokes old v6 behaviour because you use magick convert instead of plain magick, and should be avoided

是正确的现代语法

是正确的现代语法

看起来像您的意思是magick mogrify,因为您没有提供输入和输出文件名,并且因为您使用了-path,但是看起来您不小心忽略了mogrify.如果您不是偶然地省略了mogrify,那么您可能打算使用旧的convert样式的命令,并且需要输入和输出文件,并且需要在-thumbnail之前指定输入文件.

Looks like you meant magick mogrify because you didn't give input and output filenames and because you use -path, but it looks like you accidentally omitted mogrify. If you didn't accidentally omit mogrify, then you probably meant to use the old convert-style command, and need an input and an output file and you need to specify the input file before the -thumbnail.

这篇关于转换和迁移:在现代版本的ImageMagick中使用它们的正确方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆