imagekit-java icon indicating copy to clipboard operation
imagekit-java copied to clipboard

Make Result class containt Java's BufferedImage field

Open IceMajor2 opened this issue 2 years ago • 0 comments

Hi. I've been recently using ImageKit library for Java, mainly for uploading images programmatically. Throughout my not-so-long experimenting with it, I've found that it may perhaps be helpful to have a ready-to-use Java AWT's image object after having sent an image to external hosting (ImageKit :) ).

I've taken a stab at trying to accomplish so.

GOAL: Result class contains BufferedImage field

Problem: Not every file needs to be an image and not every image will neccessarily be read by ImageIO.read. In FileCreateRequest class, I've added isReadableImage field, which is set whenever any of the 3 constructors is called. In Utils, I've written isReadableImage methods. They take a reference to image source in forms of base64-encoded string, simple String path or instance of URL class. I've also written tests for them which pass (they test for both files that are images, and for simple .txt file). Note: the isReadableImage method will not return true for every image as ImageIO.read does not support every format. For example, in order to read .webp images this way, we would additionally need plugins, which I've not included.

I've also thought of creating another Result class, especially for images, but I realised it may be too much at once ;)

This is my first contribution to open source project, I'd love some feedback. I'm open to work on this as well as on other issues.

IceMajor2 avatar Jul 19 '23 14:07 IceMajor2