ImageMagick: What is this convert-command doing?

丶灬走出姿态 提交于 2020-01-05 07:08:22

问题


I'm trying to port a PHP script to Ruby and until now I only used ImageMagick to convert from one file-format to another. Meaning: Yes, I'm an ImageMagick newbie. ;-)

Somewhere inside the PHP script the following code is executed:

$output = array();
$returnValue = 0;
$cmd = 'convert '.$pngFile->path.' -resize 1x1 -alpha on -channel o -format "%[fx:u.a]" info:'
exec($cmd, $output, $returnValue);

Using the ImageMagick documentation for convert I identified the following options:

  • -resize 1x1 Resize to 1x1 pixels (right?)
  • -alpha on Activate alpha-channel
  • -channel o Apply options to the opacity image-channel

My questions:

  1. What does -format "%[fx:u.a]" exactly do? I know that u is a symbol for first image in sequence and a one for alpha. But I don't get what the whole expression really does.
  2. What does info: stand for?
  3. What does this convert-command exactly do?

Thank you very much for your kind help.

Please note: The accepted answer on the following question has a very good answer to this question:

Understanding ImageMagick's convert and translating to Ruby RMagick


回答1:


Seems like it is computing the average opacity. The info format is a dummy image format that will instruct convert to output image information to stdout (: means stdout) in the format %[fx:u.a]. Resizing to 1x1 is probably a way of averaging.



来源:https://stackoverflow.com/questions/3942046/imagemagick-what-is-this-convert-command-doing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!