Photo Album Maker Licensing Plugin
The Photo Album Maker Licensing Plugin provides a convenient solution for merging your images or photos into practical multi-page albums. You can utilize various image files in different formats from the supported image formats list to seamlessly combine them and create a single multi-page file, such as a PDF or TIFF format. Before creating a photo album, ensure you obtain a Metered license by providing your public and private keys using the `setMeteredKey()` method. In the provided Java code example, a new `tiffImage` object is created, and existing images are added using the addFrame() method. To generate a multi-page TIFF file with your images on separate pages, you can utilize the Image.create() method by passing an array of images as a parameter. Afterward, you can save the output to the file using `TiffOptions()`. Please note that utilizing unlicensed features of the Aspose.Imaging graphic library will result in a watermark appearing on the output image.
import com.aspose.imaging.Image; | |
import com.aspose.imaging.ImageOptionsBase; | |
import com.aspose.imaging.Metered; | |
import com.aspose.imaging.RasterImage; | |
import com.aspose.imaging.fileformats.tiff.TiffFrame; | |
import com.aspose.imaging.fileformats.tiff.TiffImage; | |
import com.aspose.imaging.fileformats.tiff.enums.TiffExpectedFormat; | |
import com.aspose.imaging.imageoptions.PdfOptions; | |
import com.aspose.imaging.imageoptions.TiffOptions; | |
import java.io.File; | |
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.stream.Collectors; | |
//------------------------------------------------------------------ | |
// Image album create plug-in example | |
//------------------------------------------------------------------ | |
void makeTiffAlbum(List<Image> images, TiffOptions rgbOptions, String outputPath) | |
{ | |
try (TiffImage tiffImage = new TiffImage(new TiffFrame[0])) | |
{ | |
for (Image image : images.stream().filter(image -> image instanceof RasterImage).collect(Collectors.toList())) | |
{ | |
tiffImage.addFrame(new TiffFrame((RasterImage) image, rgbOptions)); | |
tiffImage.getFrames()[tiffImage.getPageCount() - 1].grayscale(); | |
} | |
tiffImage.setActiveFrame(tiffImage.getFrames()[0]); | |
tiffImage.save(outputPath, rgbOptions); | |
} | |
} | |
void makeAlbum(List<Image> images, ImageOptionsBase imageOptions, String outputPath) | |
{ | |
try (Image image = Image.create(images.toArray(new Image[0]))) | |
{ | |
image.save(outputPath, imageOptions); | |
} | |
} | |
// Valid image album plug-in license use example | |
Metered license = new Metered(); | |
// Only metered plug-in license is supported | |
license.setMeteredKey("<your public key>", "<your private key>"); | |
// 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 outputDirectory = System.getenv("OUT_PATH"); | |
if (outputDirectory == null) | |
{ | |
outputDirectory = templatesFolder; | |
} | |
List<Image> images = new ArrayList<Image>(3); | |
String[] imagePaths = new String[]{"template.png", "template.jpg", "template.bmp"}; | |
for (String fileName : imagePaths) | |
{ | |
Image image = Image.load(templatesFolder + fileName); | |
images.add(image); | |
} | |
try | |
{ | |
String outputPath = outputDirectory + File.separator + "licensed_image_album.pdf"; | |
makeAlbum(images, new PdfOptions(), outputPath); | |
new File(outputPath).delete(); | |
// Unlicensed use | |
outputPath = outputDirectory + File.separator + "trial_image_album.tiff"; | |
makeTiffAlbum(images, new TiffOptions(TiffExpectedFormat.TiffDeflateRgba), outputPath); | |
new File(outputPath).delete(); | |
} | |
finally | |
{ | |
images.forEach(Image::close); | |
} |
Discover the features and capabilities of our free online Aspose.Imaging Photo Book Maker Application website.