ImageIO
The ImageIO class handles image reading and writing (from/to files and memory).
Definition
Namespace: com.dynamsoft.utility
public class ImageIO
Methods
| Method | Description |
|---|---|
ImageIO |
Initializes a new instance of the ImageIO class. |
readFromFile |
Reads an image from a file. |
readFromMemory |
Reads an image from a file in memory. |
readFromBase64String |
Reads an image from a Base64 string. |
saveToFile |
Saves an image to a file. |
saveToMemory |
Saves an image to a file in memory. |
saveToBase64String |
Saves an image to a Base64 string. |
ImageIO
Initializes a new instance of the ImageIO class.
ImageIO()
readFromFile
Reads an image from a file.
ImageData readFromFile(String filePath) throws UtilityException
Parameters
filePath The path of the image file.
Return value
Returns an ImageData object representing the image.
Exception
Remarks
If the file format is gif, pdf or tiff, we read the first page of the image file.
See Also
readFromMemory
Reads an image from a file in memory.
ImageData readFromMemory(byte[] fileBytes) throws UtilityException
Parameters
fileBytes A byte array representing the image file in memory.
Return value
Returns an ImageData object representing the image.
Exception
Remarks
If the file format is gif, pdf or tiff, we read the first page of the image file.
See Also
readFromBase64String
Reads an image from a Base64 string.
ImageData readFromBase64String(String base64String) throws UtilityException
Parameters
base64String A Base64 encoded string representing the image.
Return value
Returns an ImageData object representing the image.
Exception
See Also
saveToFile
Saves an image to a file.
void saveToFile(ImageData imageData, String path) throws UtilityException
void saveToFile(ImageData imageData, String path, boolean overwrite) throws UtilityException
Parameters
imageData The image data to be saved.
path The targeting file path with the file name and extension name.
overwrite A flag indicating whether to overwrite the file if it already exists. Defaults to true.
Exception
See Also
saveToMemory
Saves an image to a file in memory.
byte[] saveToMemory(ImageData imageData, @EnumImageFileFormat int imageFormat) throws UtilityException
Parameters
imageData The image data to be saved.
imageFormat The image file format to be saved.
Return value
Returns the byte array representing the saved image file.
Exception
See Also
saveToBase64String
Saves an image to a Base64 string.
String saveToBase64String(ImageData imageData, @EnumImageFileFormat int imageFormat) throws UtilityException
Parameters
imageData The image data to be saved.
imageFormat The image file format to be saved.
Return value
Returns a Base64 encoded string representing the saved image.
Exception
See Also