I am using ImageMagick to read information about various image files. I was wondering if it was possible to store the results of identify inside of an array. The reason I need to do is because of how the out put looks with gifs, as appose to one line of output it returns one for each frame which gets very muddled. I have tried multiple options but have not had much luck so far. My most recent attempt:

exec('identify -format "|%W" $img_temp', $output);

I have also tried running the above information with shell_exec as well to no avail.

If this not possible putting a unique identifier between the outputs would also be acceptable, or just limiting the result to one would also work

The question I had was if it possible to limit the results that the identify command returns.

Edit: I got it working with a unique identifier and then using explode to break it out, but I can't help but feel there is a better way of doing this.

有帮助吗?

解决方案

Im not exsactly sure what kind of output does identify but if it outputing content on diferent line could use explode("\n",$outputOfExec); and then echo the first line by echo $explodedContent[0];

$output = exec('identify -format "%W" $img_temp', $out);
$array = explode("\n",$output);
echo $array[0];
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top