Animation Maker Licensing Plugin
Leverage the Animation Maker Licensing Plugin to easily generate animations from your images. In the provided Java code example below, we initiate the configuration of Metered license settings. By employing the `setMeteredKey()` method, we enable the animation-making functionality by supplying the public and private keys. It's important to note that utilizing unlicensed features of the Aspose.Imaging graphic library for Java will result in a watermark appearing on the output images.
You can create animations from various image files in different formats from the supported image formats list. These images can seamlessly be incorporated into the output file, such as an animated GIF format. You maintain full control over animation parameters, enabling you to define the desired frame duration and overall duration. Before saving the animated GIF file to the output, loaded images can be effortlessly added using the addPage() method of the `GifImage` class.
import com.aspose.imaging.*; | |
import com.aspose.imaging.fileformats.gif.GifImage; | |
import com.aspose.imaging.fileformats.gif.IGifBlock; | |
import com.aspose.imaging.fileformats.gif.blocks.GifGraphicsControlBlock; | |
import com.aspose.imaging.imageoptions.GifOptions; | |
import com.aspose.imaging.sources.FileCreateSource; | |
import java.io.File; | |
// get path of the input data | |
String templatesFolder = System.getenv("DATA_PATH"); | |
if (templatesFolder == null) | |
{ | |
templatesFolder = "c:\\Users\\USER\\Downloads\\templates\\"; | |
} | |
// get output path | |
String outputFolder = System.getenv("OUT_PATH"); | |
if (outputFolder == null) | |
{ | |
outputFolder = templatesFolder; | |
} | |
//------------------------------------------------------------------------ | |
// Animation maker plug-in use sample | |
//------------------------------------------------------------------------ | |
// Valid Animation maker license use example | |
Metered license = new Metered(); | |
// Only metered plug-in license is supported | |
license.setMeteredKey("<your public key>", "<your private key>"); | |
String outputFilePath = templatesFolder + "/merged.gif"; | |
final int AnimationDuration = 1000; | |
final int FrameDuration = 42; | |
final File[] listFiles = new File(templatesFolder).listFiles((dir, name) -> name.endsWith(".jpg")); | |
if (listFiles == null) | |
{ | |
return; | |
} | |
GifImage gifImage = null; | |
try | |
{ | |
for (File inputFilePath : listFiles) | |
{ | |
RasterImage sourceImage = (RasterImage)Image.load(inputFilePath.getAbsolutePath()); | |
if (gifImage == null) | |
{ | |
GifOptions createOptions = new GifOptions() | |
{{ | |
setSource(new FileCreateSource(outputFilePath, false)); | |
setBackgroundColor(Color.getTransparent()); | |
setFullFrame(true); | |
setLoopsCount(AnimationDuration / FrameDuration); | |
setPalette(ColorPaletteHelper.getCloseImagePalette(sourceImage, 256)); | |
}}; | |
gifImage = (GifImage)Image.create( | |
createOptions, | |
sourceImage.getWidth(), | |
sourceImage.getHeight()); | |
gifImage.insertBlock(0, new GifGraphicsControlBlock()); | |
gifImage.setFrameTime(FrameDuration); | |
if (gifImage.getPageCount() > 1) | |
{ | |
gifImage.removeBlock((IGifBlock) gifImage.getPages()[1]); | |
} | |
} | |
// add frame | |
gifImage.addPage(sourceImage); | |
} | |
} | |
finally | |
{ | |
if (gifImage != null) | |
{ | |
gifImage.save(); // save to the merged.gif | |
gifImage.close(); // dispose | |
} | |
} |
Explore the functionalities and potential of our free online Aspose.Imaging Animation Maker Web Application.