• Post Reply Bookmark Topic Watch Topic
  • New Topic

Get File Type

 
Niall Loughnane
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Anyone know how to do the following:

- when i right click on a file whether in windows or linux the properties of the file comes up, i.e. name: x.jpg, Type: JPEG image, size: 30kb

- if i change the file extension of the file to x.png, the type: JPEG image remains the same i.e. Type: JPEG image

i have tried using javax.activation to get the mime type but this seems to work off the extension of the file

anyone know any library or example code?

Cheers,

Niall
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what you are trying to do: convert an image from one type to another, or just find out which type an image is? If the latter, then that's what the ImageInfo class does.
 
Niall Loughnane
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i was thinking about ImageInfo but sometimes the file that we are trying to check for the file format (i.e. image/jpeg, image/tiff) is not an image but a video file (video/mpeg, video/x-msvideo) or some other type of file, so i cant use ImageInfo :-(
 
Sahid Khan
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
perhaps, you can use jmimemagic
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!