使用识别时,imagemagick 在动画 gif 上返回大量尺寸值
我在使用 imagemagick 的识别命令获取图像的尺寸时遇到问题:
identify -format "%w^%h"
对于动画 gif,它返回大型数组,例如:
Array ( [0] => 500 [1] => 322500 [2] => 322307 [3] => 178151 [4] => 322500 [5] => 178500 [6] => 322500 [7] => 322500 [8] => 322500 [9] => 302500 [10] => 322306 [11] => 303500 [12] => 303500 [13] => 322500 [14] => 317381 [15] => 322500 [16] => 322500 [17] => 178500 [18] => 178500 [19] => 322151 [20] => 322500 [21] => 178500 [22] => 322500 [23] => 322500 [24] => 322500 [25] => 302500 [26] => 322306 [27] => 303500 [28] => 303500 [29] => 322500 [30] => 317381 [31] => 322500 [32] => 322500 [33] => 178500 [34] => 178500 [35] => 322151 [36] => 322500 [37] => 178500 [38] => 322500 [39] => 322500 [40] => 322500 [41] => 302500 [42] => 322306 [43] => 303500 [44] => 303500 [45] => 322500 [46] => 317381 [47] => 322500 [48] => 322500 [49] => 178500 [50] => 178500 [51] => 322151 [52] => 322500 [53] => 178500 [54] => 322500 [55] => 322500 [56] => 322500 [57] => 302500 [58] => 322306 [59] => 303500 [60] => 303500 [61] => 322500 [62] => 317381 [63] => 322500 [64] => 322500 [65] => 178500 [66] => 178500 [67] => 322151 [68] => 322500 [69] => 178500 [70] => 322500 [71] => 322500 [72] => 322500 [73] => 302500 [74] => 322306 [75] => 303500 [76] => 303500 [77] => 322500 [78] => 317381 [79] => 322500 [80] => 322500 [81] => 17827 [82] => 2127 [83] => 2127 [84] => 2127 [85] => 2127 [86] => 2127 [87] => 21 )
我假设它正在获取每个帧的尺寸。这使得很难获得正确的尺寸,在本例中为 (500x322)。我能做些什么?
I am having trouble getting the dimensions of an image using imagemagick's identify command:
identify -format "%w^%h"
For animated gifs it returns large arrays such as:
Array ( [0] => 500 [1] => 322500 [2] => 322307 [3] => 178151 [4] => 322500 [5] => 178500 [6] => 322500 [7] => 322500 [8] => 322500 [9] => 302500 [10] => 322306 [11] => 303500 [12] => 303500 [13] => 322500 [14] => 317381 [15] => 322500 [16] => 322500 [17] => 178500 [18] => 178500 [19] => 322151 [20] => 322500 [21] => 178500 [22] => 322500 [23] => 322500 [24] => 322500 [25] => 302500 [26] => 322306 [27] => 303500 [28] => 303500 [29] => 322500 [30] => 317381 [31] => 322500 [32] => 322500 [33] => 178500 [34] => 178500 [35] => 322151 [36] => 322500 [37] => 178500 [38] => 322500 [39] => 322500 [40] => 322500 [41] => 302500 [42] => 322306 [43] => 303500 [44] => 303500 [45] => 322500 [46] => 317381 [47] => 322500 [48] => 322500 [49] => 178500 [50] => 178500 [51] => 322151 [52] => 322500 [53] => 178500 [54] => 322500 [55] => 322500 [56] => 322500 [57] => 302500 [58] => 322306 [59] => 303500 [60] => 303500 [61] => 322500 [62] => 317381 [63] => 322500 [64] => 322500 [65] => 178500 [66] => 178500 [67] => 322151 [68] => 322500 [69] => 178500 [70] => 322500 [71] => 322500 [72] => 322500 [73] => 302500 [74] => 322306 [75] => 303500 [76] => 303500 [77] => 322500 [78] => 317381 [79] => 322500 [80] => 322500 [81] => 17827 [82] => 2127 [83] => 2127 [84] => 2127 [85] => 2127 [86] => 2127 [87] => 21 )
I am assuming it is getting the dimensions of each frame. This is making it difficult to get the correct dimensions which is (500x322) in this case. What can I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这应该可行 - ImageMagick 将以可爆炸的格式将信息打印在一行上,然后转到下一行。您可能需要跳过
$output
的最后一行,因为它可能设置为空白。That should work - ImageMagick will print the info on one line in an
explode
-able format and then go to the next line. You may need to skip the last line of$output
as it may be set to blank.