troubleshooting Question

Ensure that BufferedImage is of a specific type

Avatar of InteractiveMind
InteractiveMindFlag for United Kingdom of Great Britain and Northern Ireland asked on
15 Comments1 Solution485 ViewsLast Modified:

I've got a lot of image files - some are JPEG's, GIF's, PNG's, BMP's, etc..

What I'm currently doing is reading each file into a BufferedImage, like so:

   BufferedImage img = my_image_file );

Now, I need all of the BufferedImage instance's to be of the type:


Is there a way to ensure that each file is read into this type? If not, then can I convert the type of a BufferedImage instance?

For example:

   BufferedImage img = my_image_file );
   if ( img.getType() != BufferedImage.TYPE_INT_RGB )
      // Convert here . . .

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 15 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 15 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros