【问题标题】:identify -verbose returns Imagemagick version instead of image properitesidentify -verbose 返回 Imagemagick 版本而不是图像属性
【发布时间】:2016-07-01 16:42:08
【问题描述】:

Imagemagick 有一个奇怪的问题。

按照 imagemagick.org 的示例使用说明:

$identify = exec("identify $original_file");

此命令提供类似于以下的输出:

rose.jpg JPEG 70x46 70x46+0+0 8 位 sRGB 2.36KB 0.000u 0:00.000

它确实很好。

下一个命令应该给出一个很长的所有不同属性的列表:

$identify = exec("identify -verbose $original_file");

但这是我得到的:

string(79) " 版本:ImageMagick 6.8.9-9 Q16 x86_64 2016-06-01 www.imagemagick.org"

无论图像如何,我都会得到这个。如果找不到任何东西,文档中没有任何关于它默认为版本的内容,并且日志中没有错误,所以我有点卡住了。任何帮助都会非常感谢!

【问题讨论】:

  • 你能在命令行中测试命令吗?
  • 从命令行获取图像属性!

标签: php imagemagick


【解决方案1】:

如果您查看此页面上的示例http://www.imagemagick.org/script/identify.php,则版本是命令的最后一行输出。我认为当您使用该变量时,它会以某种方式覆盖其他信息。

echo "<pre>";
system("identify -verbose $original_file");
echo "</pre>";

这应该将信息输出到屏幕上;它显示什么?

编辑 我发现这行得通:

$original_file = "input.jpg";
$identify = exec("identify -verbose $original_file", $path);
print_r($path);

【讨论】:

    【解决方案2】:

    我可以建议您尝试在捕获输出的exec() 中添加一个额外的参数,如下所示:

    <?php
       $identify = exec("identify -verbose copyright.jpg",$output);
       var_dump($output);
    ?>
    

    样本输出

    array(88) {
      [0]=>
      string(20) "Image: copyright.jpg"
      [1]=>
      string(61) "  Format: JPEG (Joint Photographic Experts Group JFIF format)"
      [2]=>
      string(23) "  Mime type: image/jpeg"
      [3]=>
      string(20) "  Class: DirectClass"
      [4]=>
      string(21) "  Geometry: 10x12+0+0"
      [5]=>
      string(18) "  Units: Undefined"
      [6]=>
      string(15) "  Type: Palette"
      [7]=>
      string(22) "  Endianess: Undefined"
      [8]=>
      string(18) "  Colorspace: sRGB"
      [9]=>
      string(14) "  Depth: 8-bit"
      [10]=>
      string(16) "  Channel depth:"
      [11]=>
      string(14) "    red: 8-bit"
      [12]=>
      string(16) "    green: 1-bit"
      [13]=>
      string(15) "    blue: 1-bit"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-11-17
      • 2013-08-15
      • 2015-05-23
      • 1970-01-01
      • 1970-01-01
      • 2014-11-08
      • 2021-05-14
      相关资源
      最近更新 更多