【问题标题】:Usage of value returned by 'identify' utility of ImageMagick in CMD在 CMD 中使用 ImageMagick 的“识别”实用程序返回的值
【发布时间】:2013-09-12 09:13:21
【问题描述】:

一行的开头

identify -format %w input.jpg

在命令提示符中导致打印图像的宽度。

我必须将此值分配给 CMD 文件中的某个变量,以便在脚本中进一步使用此变量。我该怎么做?

我需要这样的代码:

@echo OFF  
set width=identify -format %w input.jpg
rem ...further usage of %width%...

但是,它不起作用。

P.S.:this answer 中提供的代码几乎是我需要的,但我需要 CMD 脚本的代码。

【问题讨论】:

  • 获取输出的代码取决于输出。
  • 当我从命令行启动identify -format %w input.jpg 时,会在下一行打印类似“1600”(我的意思是,只是一个数字,一个图像宽度)的内容。我不知道这是否有帮助。

标签: cmd imagemagick call external identify


【解决方案1】:

你可以试试这个:

for /f %%a in ('identify -format %%w input.jpg') do set "width=%%~a"
echo %width%

【讨论】:

  • 这就是我想要的。非常感谢!
猜你喜欢
  • 1970-01-01
  • 2011-08-13
  • 2014-02-26
  • 2019-01-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-01-27
  • 1970-01-01
相关资源
最近更新 更多