小编Ari*_* A.的帖子

调整 GIF 大小会丢失动画

我正在使用 GraphicsMagick (1.3.16) 和 im4java (1.4.0) 来创建 GIF 的缩略图。在命令行中,我可以执行以下操作:

convert original.gif -coalesce -resize 100x100 +profile * thumb.gif
Run Code Online (Sandbox Code Playgroud)

并成功创建缩略图,保留动画。但是我的应用程序中的某些内容没有翻译,因为看似相同/相似的命令:

- -coalesce -resize 100x100 +profile * gif:- 
Run Code Online (Sandbox Code Playgroud)

创建仅捕获动画的单个图像的缩略图。注意:输入通过管道输入,输出作为 BufferedImage 捕获。

如果有帮助,这里是用于创建我正在使用的上述 cmd 的代码块:

public static BufferedImage createThumb(byte[] imageFileData)
{
  GMOperation op = new GMOperation();
  op.addImage("-"); // input: stdin
  op.coalesce();
  op.resize(100, 100);
  op.p_profile("*");
  op.addImage("gif:-"); // output: stdout

  ConvertCmd cmd = new ConvertCmd(true); // use GraphicsMagick

  // Pipe the fileData to stdin, to avoid writing to a file first.
  ByteArrayInputStream bais = new ByteArrayInputStream(imageFileData); …
Run Code Online (Sandbox Code Playgroud)

graphicsmagick im4java

5
推荐指数
0
解决办法
939
查看次数

标签 统计

graphicsmagick ×1

im4java ×1