Package com.idrsolutions.image
Class JDeli
- java.lang.Object
-
- com.idrsolutions.image.JDeliImage
-
- com.idrsolutions.image.JDeli
-
public class JDeli extends com.idrsolutions.image.JDeliImage
Class reads and writes image files.Example to read an image, where:
- imageFile is of type File
JDeli.read(imageFile);
Example to write an image, where:
- image is of type BufferedImage
- outputFormat is of type OutputFormat
- outputFile is of type File
JDeli.write(image, OutputFormat.PNG, outputFile); or JDeli.write(image, "png", outputFile); or JDeli.write(image, "png", outputStream);
-
-
Constructor Summary
Constructors Constructor Description JDeli()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]
convert(byte[] inputData, String format)
static void
convert(File inputFile, File outputFile)
Convert between any supported image file formatsstatic void
convert(File inputFile, File outputFile, ImageProcessingOperations conversions)
Convert between any supported image file formats and process imagestatic void
convert(InputStream inputFile, OutputStream outputFile, String format)
static Metadata
getImageInfo(String imageFile)
Returns Metadata object describing Imagestatic boolean
isImageSupportedForInput(String formatName)
return whether the image format name is supported for reading fromstatic boolean
isImageSupportedForOutput(String formatName)
return whether the image format name is supported for writingstatic void
main(String[] args)
static BufferedImage
process(ImageProcessingOperations conversions, BufferedImage image)
Returns BufferedImage with processing options appliedstatic BufferedImage
read(byte[] data)
Returns BufferedImage as the result of decoding a supplied image file bytes
This method can open files with extension of jpg, jpeg, jp2, jpx, dcm, png, apng, tiff, gif, webp, sgi, rgb, psd and bmp.static BufferedImage
read(byte[] data, HashMap<String,String> map)
Returns BufferedImage as the result of decoding a supplied imagefile
This method can open files with extension of jpg, jpeg, jp2, jpx, dcm, png, apng, tiff, gif, webp, sgi, rgb, psd and bmp.static BufferedImage
read(File imageFile)
Returns BufferedImage as the result of decoding a supplied imagefile
This method can open files with extension of jpg, jpeg, jp2, jpx, dcm, png, apng, tiff, gif, webp, sgi, rgb, psd and bmp.static BufferedImage
read(File imageFile, HashMap<String,String> map)
Returns BufferedImage as the result of decoding a supplied imagefile
This method can open files with extension of jpg, jpeg, jp2, jpx, dcm, png, apng, tiff, gif, webp, sgi, rgb, psd and bmp.static BufferedImage
read(InputStream is)
Returns BufferedImage as the result of decoding a supplied image input stream
This method can open files with extension of jpg, jpeg, jp2, jpx, dcm, png, apng, tiff, gif, webp, sgi, rgb, psd and bmp.static BufferedImage
read(InputStream is, HashMap<String,String> map)
Returns BufferedImage as the result of decoding a supplied image input stream
This method can open files with extension of jpg, jpeg, jp2, jpx, dcm, png, apng, tiff, gif, webp, sgi, rgb, psd and bmp.static void
write(BufferedImage image, EncoderOptions options, File outputFile)
This method compress the buffered image into given output formatstatic void
write(BufferedImage image, EncoderOptions options, OutputStream outputStream)
This method compress the buffered image into given output formatstatic void
write(BufferedImage image, OutputFormat format, File outputFile)
This method compress the buffered image into given output formatstatic void
write(BufferedImage image, OutputFormat format, OutputStream outputStream)
This method compress the buffered image into given output formatstatic void
write(BufferedImage image, String formatName, File outputFile)
This method compress the buffered image into given output format Available format names are "jpg", "png", "tiff", "bmp", "pdf"
Please note : we will be adding more formats in futurestatic void
write(BufferedImage image, String formatName, OutputStream stream)
This method compress the buffered image into given output format Available format names are "jpg", "jp2", "jpx", "png", "tiff", "bmp"
Please note : we will be adding more formats in future
-
-
-
Method Detail
-
convert
public static void convert(File inputFile, File outputFile) throws Exception
Convert between any supported image file formats- Parameters:
inputFile
-outputFile
-- Throws:
Exception
-
convert
public static void convert(File inputFile, File outputFile, ImageProcessingOperations conversions) throws Exception
Convert between any supported image file formats and process image- Parameters:
inputFile
-outputFile
-conversions
-- Throws:
Exception
-
process
public static BufferedImage process(ImageProcessingOperations conversions, BufferedImage image)
Returns BufferedImage with processing options applied- Returns:
- BufferedImage
-
convert
public static void convert(InputStream inputFile, OutputStream outputFile, String format) throws Exception
- Throws:
Exception
-
convert
public static byte[] convert(byte[] inputData, String format) throws Exception
- Throws:
Exception
-
getImageInfo
public static Metadata getImageInfo(String imageFile) throws Exception
Returns Metadata object describing Image- Parameters:
imageFile
-- Returns:
- Specific instance of Metadata (ie BMPMetadata)
- Throws:
Exception
-
read
public static BufferedImage read(File imageFile) throws Exception
Returns BufferedImage as the result of decoding a supplied imagefile
This method can open files with extension of jpg, jpeg, jp2, jpx, dcm, png, apng, tiff, gif, webp, sgi, rgb, psd and bmp.- Parameters:
imageFile
-- Returns:
- BufferedImage
- Throws:
Exception
-
read
public static BufferedImage read(File imageFile, HashMap<String,String> map) throws Exception
Returns BufferedImage as the result of decoding a supplied imagefile
This method can open files with extension of jpg, jpeg, jp2, jpx, dcm, png, apng, tiff, gif, webp, sgi, rgb, psd and bmp.- Parameters:
imageFile
-map
- map to put custom parameters- Returns:
- BufferedImage
- Throws:
Exception
-
read
public static BufferedImage read(byte[] data, HashMap<String,String> map) throws Exception
Returns BufferedImage as the result of decoding a supplied imagefile
This method can open files with extension of jpg, jpeg, jp2, jpx, dcm, png, apng, tiff, gif, webp, sgi, rgb, psd and bmp.- Parameters:
data
- compressed image data as bytesmap
- map to put custom parameters- Returns:
- BufferedImage
- Throws:
Exception
-
read
public static BufferedImage read(byte[] data) throws Exception
Returns BufferedImage as the result of decoding a supplied image file bytes
This method can open files with extension of jpg, jpeg, jp2, jpx, dcm, png, apng, tiff, gif, webp, sgi, rgb, psd and bmp.- Parameters:
data
- raw image bytes- Returns:
- BufferedImage
- Throws:
Exception
-
read
public static BufferedImage read(InputStream is, HashMap<String,String> map) throws Exception
Returns BufferedImage as the result of decoding a supplied image input stream
This method can open files with extension of jpg, jpeg, jp2, jpx, dcm, png, apng, tiff, gif, webp, sgi, rgb, psd and bmp.- Parameters:
is
- input stream to read from- Returns:
- BufferedImage
- Throws:
Exception
-
read
public static BufferedImage read(InputStream is) throws Exception
Returns BufferedImage as the result of decoding a supplied image input stream
This method can open files with extension of jpg, jpeg, jp2, jpx, dcm, png, apng, tiff, gif, webp, sgi, rgb, psd and bmp.- Parameters:
is
- input stream to read from- Returns:
- BufferedImage
- Throws:
Exception
-
write
public static void write(BufferedImage image, EncoderOptions options, File outputFile) throws Exception
This method compress the buffered image into given output format- Parameters:
image
- bufferedImageoptions
- WriterOptionsoutputFile
- output file- Throws:
Exception
- See Also:
OutputFormat
-
write
public static void write(BufferedImage image, OutputFormat format, File outputFile) throws Exception
This method compress the buffered image into given output format- Parameters:
image
- bufferedImageformat
- output formatoutputFile
- output file- Throws:
Exception
- See Also:
OutputFormat
-
write
public static void write(BufferedImage image, String formatName, File outputFile) throws Exception
This method compress the buffered image into given output format Available format names are "jpg", "png", "tiff", "bmp", "pdf"
Please note : we will be adding more formats in future- Parameters:
image
- bufferedImageformatName
- output format nameoutputFile
- output file- Throws:
Exception
- See Also:
OutputFormat
-
isImageSupportedForOutput
public static boolean isImageSupportedForOutput(String formatName)
return whether the image format name is supported for writing- Parameters:
formatName
-- Returns:
-
isImageSupportedForInput
public static boolean isImageSupportedForInput(String formatName)
return whether the image format name is supported for reading from- Parameters:
formatName
-- Returns:
-
write
public static void write(BufferedImage image, String formatName, OutputStream stream) throws Exception
This method compress the buffered image into given output format Available format names are "jpg", "jp2", "jpx", "png", "tiff", "bmp"
Please note : we will be adding more formats in futureThis method does not close the provided OutputStream after the write operation has completed; it is the responsibility of the caller to close the stream.
- Parameters:
image
- bufferedImageformatName
- output format namestream
- output stream- Throws:
Exception
-
write
public static void write(BufferedImage image, EncoderOptions options, OutputStream outputStream) throws Exception
This method compress the buffered image into given output formatThis method does not close the provided OutputStream after the write operation has completed; it is the responsibility of the caller to close the stream.
- Parameters:
image
- bufferedImageoptions
- WriterOptionsoutputStream
- outputStream- Throws:
Exception
- See Also:
OutputFormat
-
write
public static void write(BufferedImage image, OutputFormat format, OutputStream outputStream) throws Exception
This method compress the buffered image into given output formatThis method does not close the provided OutputStream after the write operation has completed; it is the responsibility of the caller to close the stream.
- Parameters:
image
- bufferedImageformat
- output formatoutputStream
- outputStream- Throws:
Exception
- See Also:
OutputFormat
-
-