需要以 PNG 图像 GIF 格式吗?随着Aspose.Words for Java任何开发人员可以轻松地将 PNG 成 GIF 只需几行 Java 代码。
现代图像处理 Java API 从 PNG 图片高速 GIF 直接在浏览器中 PNG 到 GIF 图像转换的质量。强大的 Java 库允许将 PNG 图像转换为许多流行的图形格式。
以下示例演示如何将 PNG 中的 GIF Java 。
按照简单的步骤将 PNG 转换为 GIF 格式。从本地驱动器读取 PNG 图像,然后将其保存为 GIF GIF 扩展名指定所需的图像格式。对于 PNG 读取和 GIF 写入,您可以使用完全限定的文件名。输出 GIF 内容将与原始 PNG 图像相同。
import com.aspose.words.*;
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = builder.insertImage("Input.png");
shape.getShapeRenderer().save("Output.gif", new ImageSaveOptions(SaveFormat.GIF));
import com.aspose.words.*;
Document doc = new Document("Input.png");
doc.save("Output.gif");
import com.aspose.words.*;
Document doc = new Document("Input.png");
for (int page = 0; page < doc.getPageCount(); page++)
{
Document extractedPage = doc.extractPages(page, 1);
extractedPage.save(String.format("Output_%d.gif", page + 1));
}
import com.aspose.words.*;
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.insertImage("Input.png");
doc.save("Output.gif");
import com.aspose.words.*;
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = builder.insertImage("Input.png");
shape.getShapeRenderer().save("Output.gif", new ImageSaveOptions(SaveFormat.gif));
我们在Maven存储库中托管我们的 Java 'Aspose.Words for Java' 是一个常见的包含字节码的 JAR 请按照有关如何将其安装到 Java 开发人员环境的分步说明进行操作。
Java SE 7 和更新的 Java 版本。 Java SE 6 提供了一个单独的包,以防您不得不使用这个过时的 JRE 。
我们的 Java 包是跨平台的,可以在所有具有 JVM 实现的 Microsoft Windows 、Linux、macOS、Android 和 iOS。
有关可选包依赖项的信息,例如 JogAmp JOGL 、 Harfbuzz 字体引擎、 Java Advanced Imaging JAI ,请参阅产品文档。
您可以将PNG转换为许多其他文件格式: