Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaFX: Get format (PNG, JPG..) of an image?

I am creating an application that for some reasons shall only accept PNG images.

How can I check if an image is really a PNG image? Currently I am using the JavaFX 2 Image class to load the image.

Thanks for any hint!

like image 321
stefan.at.wpf Avatar asked Nov 26 '25 19:11

stefan.at.wpf


1 Answers

I do this currently in my own application by confirming the file's Mime Type before I process it. There are several SO threads suggesting how to obtain Mime Types in Java.

  • Getting A File's Mime Type In Java
  • java library to find the mime type from file content
like image 147
JoshDM Avatar answered Nov 28 '25 07:11

JoshDM