翻譯|使用教程|編輯:李顯亮|2021-03-26 09:33:28.720|閱讀 325 次
概述:通常,GIF圖像用于描述動畫。動畫GIF是按特定順序組合在一起的幀的集合。但是,在某些情況下,必須將GIF圖像轉換為其他光柵圖像格式。對于這種情況,本文演示了如何使用Java將GIF圖像轉換為PNG,JPEG,BMP和TIFF格式。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
通常,GIF圖像用于描述動畫。動畫GIF是按特定順序組合在一起的幀的集合。但是,在某些情況下,必須將GIF圖像轉換為其他光柵圖像格式。對于這種情況,本文演示了如何使用Java將GIF圖像轉換為PNG,JPEG,BMP和TIFF格式。
Aspose.Imaging是功能豐富的圖像處理API,可讓您處理和轉換各種圖像格式。尤其是,API提供了高保真的GIF圖像到PDF格式的轉換。還沒使用過的朋友可以點擊下載最新版
以下是使用Java將GIF圖像轉換為PNG的步驟。
以下代碼示例顯示了如何使用Java將GIF圖像轉換為PNG。
// Load GIF image com.aspose.imaging.Image image = com.aspose.imaging.Image.load("image.gif"); // Set image options com.aspose.imaging.imageoptions.PngOptions options = new com.aspose.imaging.imageoptions.PngOptions(); // Specify the frame to be converted com.aspose.imaging.imageoptions.MultiPageOptions multiPageOptions = new com.aspose.imaging.imageoptions.MultiPageOptions( new com.aspose.imaging.IntRange(2, 2)); // Convert frame of GIF to JPG options.setMultiPageOptions(multiPageOptions); // Save PNG image image.save("gif-to-png.png", options);
以下是使用Java將GIF圖像轉換為JPEG的步驟。
以下代碼示例顯示了如何在Java中將GIF圖像轉換為JPEG。
// Load GIF image com.aspose.imaging.Image image = com.aspose.imaging.Image.load("image.gif"); // Set image options com.aspose.imaging.imageoptions.JpegOptions options = new com.aspose.imaging.imageoptions.JpegOptions(); // Specify the frame to be converted com.aspose.imaging.imageoptions.MultiPageOptions multiPageOptions = new com.aspose.imaging.imageoptions.MultiPageOptions( new com.aspose.imaging.IntRange(2, 2)); // Convert frame of GIF to JPG options.setMultiPageOptions(multiPageOptions); // Save JPG image image.save("gif-to-jpg.jpg", options);
以下是使用Java將GIF圖像轉換為BMP的步驟。
以下代碼示例顯示了如何在Java中將GIF圖像轉換為BMP。
// Load GIF image com.aspose.imaging.Image image = com.aspose.imaging.Image.load("image.gif"); // Set image options com.aspose.imaging.imageoptions.BmpOptions options = new com.aspose.imaging.imageoptions.BmpOptions(); // Convert first frame of GIF to BMP options.setMultiPageOptions(new com.aspose.imaging.imageoptions.MultiPageOptions(1)); // Save BMP image image.save("gif-to-bmp.bmp", options);
以下是使用Java將GIF圖像轉換為TIFF的步驟。
以下代碼示例顯示了如何在Java中將GIF圖像轉換為TIFF。
// Input file's name String fileName = "Animation.gif"; // Output files String outputFilePath = "_FullFrame.tif"; String outputFilePath1 = "_NonFullFrame.tif"; // Load GIF image try (com.aspose.imaging.Image image = com.aspose.imaging.Image.load(fileName)) { // Set multipage options com.aspose.imaging.imageoptions.MultiPageOptions multiPageOptions = new com.aspose.imaging.imageoptions.MultiPageOptions(new com.aspose.imaging.IntRange(2, 5)); com.aspose.imaging.imageoptions.TiffOptions tiffOptions = new com.aspose.imaging.imageoptions.TiffOptions(TiffExpectedFormat.TiffDeflateRgb); tiffOptions.setMultiPageOptions(multiPageOptions); // Set frame size tiffOptions.setFullFrame(true); image.save(outputFilePath, tiffOptions); tiffOptions.setFullFrame(false); // Save as TIFF image.save(outputFilePath1, tiffOptions); }
如果你想試用Aspose的全部完整功能,可聯系在線客服獲取30天臨時授權體驗。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn