ImageMagick命令行选项顺序(和命令行参数的类别) [英] ImageMagick Command-Line Option Order (and Categories of Command-Line Parameters)

查看:191
本文介绍了ImageMagick命令行选项顺序(和命令行参数的类别)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的主管要求我将使用PerlMagick的Perl脚本部分转换为管道并使用命令行版本的ImageMagick(出于各种不相关的原因)。

My supervisor has asked me to convert the parts of our Perl scripts that use PerlMagick to instead pipe and use the command line version of ImageMagick (for various unrelated reasons).

使用我们现有的界面(裁剪,缩放,保存等)我正在构建一个用户想要在图像上执行的操作列表,构造语句以进行管道然后执行它。

Using the our existing interface (crop, scale, save, etc) I'm building up a list of operations the user wants to perform on an image, constructing the statement to pipe and then executing it.

我想知道的是:


  1. 转换操作是从左到右执行的?即我通过的顺序

  2. 如果我两次传递相同的选项会怎样?它们是单独执行的吗?

显然,对图像执行操作的顺序至关重要,所以我正在努力解决如果我可以一次性执行所有操作(可能获得效率?),或者如果它我将不得不分别执行每个操作。
谢谢

Obviously the order in which operations are performed on an image is vital, so I'm trying to work out if I can perform all of the operations in one go (possibly gaining efficiency?) or if it I'm going to have to perform each operation separately. Thanks

推荐答案

不幸的是,这个问题的接受答案还没有完成......: - )

Unfortunately, the accepted answer to this question is not yet complete... :-)

假设您的ImageMagick版本是最新版本,这是一个重要修订它:

Assuming, your ImageMagick version is a recent one, here is an important amendment to it:


  • 你应该区分3大类命令行参数:

  • you should differentiate between 3 major classes of command line parameters:


  1. 图片设置

  2. 图片运营商

  3. 图像序列运算符

     

  1. Image Settings
  2. Image Operators
  3. Image Sequence Operators
     


这三个类的行为有所不同:

These three classes do behave differently:


  1. 图片设置


  1. 图片设置在命令行中显示为持久。
    它可能影响所有后续处理(但不是之前的处理):

  1. An image setting persists as it appears on the command line. It may affect all subsequent processing (but not previous processing):


  • 处理如阅读稍后在命令行中生成一个或多个图像;

  • 由以下图像操作员完成的处理;

  • 通过将图像作为输出进行处理。

     

图片设置保持有效状态.. 。

An image setting stays in effect...


  • ...直到重置或由相同类型的其他设置替换,

  • ...或直到命令行终止。

     


  • 图片运算符


    1. 图片运算符应用于(单个)图像并被遗忘。
      它与图像设置不同,因为它会立即影响图像,因为它出现在命令行上。
      (请记住:图像设置会一直存在,直到命令行终止,或直到重置为止。)

    1. An image operator is applied to a (single) image and forgotten. It differs from an image setting because it affects the image immediately as it appears on the command line. (Remember: an image setting which persists until the command line terminates, or until it is reset.)

    如果您需要将同一图像 operator 应用于同一命令行中的第二个图像,则必须在命令行上重复该确切的运算符。

    If you need to apply the same image operator to a second image in the same commandline, you have to repeat that exact operator on the commandline.

    严格地说,根据ImageMagick命令行的新架构,所有图像运算符应在加载图像后写入
    然而,IM开发者妥协:为了向后兼容性,
    ,图像操作员仍然可以在加载图像之前出现 - 然后它们将应用于他们可用的第一张图像。

    Strictly speaking, in compliance with the new architecture of ImageMagick command lines, all image operators should be written after the loading of the image it is meant for. However, the IM developers compromised: in the interest of backward compatibility, image operators can still appear before loading an image -- they will then be applied to the first image that is available to them.


  • 图像序列运算符


    1. 图像序列运算符应用于所有当前加载的图像(然后被遗忘)。

    1. An image sequence operator is applied to all currently loaded images (and then forgotten).

    它与简单的图像操作符的不同之处在于它不仅影响单个图像。
    (有些运营商只有在他们的操作有多个图像供消费时才有意义:想想 -append -combine -composite -morph ...)

    It differs from a simple image operator in that it does not only affect a single image. (Some operators only make sense if their operation has multiple images for consumption: think of -append, -combine, -composite, -morph...)


  • 从以上原则可以得出结论:在大多数情况下,命令行参数的顺序很重要(如果你知道他们做了什么,你也知道你需要使用哪个顺序来应用它们。)

    From above principles you can already conclude: the order of the command line parameters is significant in most cases. (If you know what they do, you also know which order you need to use applying them.)

    (为了完整起见,我应该补充:还有另一类 miscellanious 其他参数,它们不属于上面列出的任何类别。想想 -debug -verbose -version 。)

    (For completeness' sake I should add: there is another class of miscellanious, or other parameters, which do not fall into any of the above listed categories. Think -debug, -verbose or -version.)

    不幸的是,3类IM命令行参数之间的明显区别还不是(在其他非常精明的)IM用户之间的常识。因此,获得更多曝光是值得的。

    Unfortunately, the clear distinction between the 3 classes of IM command line paramaters is not yet common knowledge among (otherwise quite savvy) IM users. So it merits to get much more exposure.

    ImageMagick主要版本6引入了这种明显的差异化。之前,它更令人困惑:一些设置的语义随着上下文而变化他们也得到了命令。复杂命令的结果并不总是可预测的,有时令人惊讶和不合逻辑。 (现在它们有时也会令人惊讶,但是当你仔细观察它们时,理解上面的内容,它们总是很符合逻辑。)

    This clear differentiation was introduced with ImageMagick major version 6. Before, it was more confusing: some settings' semantics changed with context and also with the order they were given. Results from complex commands were not always predictable and sometimes surprising and illogical. (Now they may be surprising too sometimes, but when you closely look at them, understanding the above, they are always quite logical.)

    每当你不确定一个特定参数属于哪个类时,运行

    Whenever you are not sure, which class one particular parameter belongs to, run

     convert -help | less
    

    搜索您的参数。找到后,向后滚动:然后您应该找到它出现的标题。现在您可以确定它是哪种类型:图像设置图像操作员图像序列操作员 - 并考虑到以上我对他们的看法。

    Search for your parameter. Once found, scroll back: you should then find the "heading" under which it appears. Now you can be sure which type it is: an Image Setting, an Image Operator, or an Image Sequence Operator -- and take into account what I've said about them above.

    如果你的工作是移植你的ImageMagick从PerlMagick到CLI的界面,您应该知道另一个技巧:您可以插入

    If your job is to port your ImageMagick interface from PerlMagick to CLI, you should be aware of one other trick: You can insert

     +write output-destination
    

    命令行上的任何地方(甚至多次)。然后,这将把当前处理的状态下当前加载的图像(或当前加载的图像序列)写出到给定的输出目的地。 (将其视为类似于 tee - 的shell /终端使用命令,该命令重定向 em> < stdout> 到文件中。)输出目的地可以是文件,或者 show:或其他对IM输出有效的内容。写入输出后,将继续处理完整的命令。

    anywhere on the command line (even multiple times). This will then write out the currently loaded image (or the currently loaded image sequence) in its currently processed state to the given output destination. (Think of it as something similar as the tee-command for shell/terminal usage, which re-directs a copy of <stdout> into a file.) Output destination can be a file, or show: or whatever else is valid for IM outputs. After writing to the output, processing of the complete command will continue.

    当然,只插入 + write 在第一个(或任何其他)图像运算符之后 - 否则当前图像列表将不会更改。

    Of course, it only makes sense to insert +write after the first (or any other) image operator -- otherwise the current image list will not have changed.

    是否应该通过多个输出图像(因为当前图像列表包含多个图像),然后ImageMagick会自动为各自的文件名分配索引编号。

    Should there by multiple output images (because the current image list consists of more than one image), then ImageMagick will automatically assign index numbers to the respective filename.

    这是一个很好的帮助调试(或优化,简化,简化......)复杂的命令设置。

    This is a great help with debugging (or optimizing, streamlining, simplifying...) complex command setups.

    这篇关于ImageMagick命令行选项顺序(和命令行参数的类别)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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