我正在使用 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)