Given a file path what is the easiest way of know if that file is a image (of any kind) in Java(Android)? Thanks
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There are external tools that can help you do this. Check out JMimeMagic and JMagick. You can also attempt to read the file using the
ImageIOclass, but that can be costly and is not entirely foolproof.This question has been asked on SO a couple of times. See these additional threads on the same topic:
Check if a file is an image
How to check a uploaded file whether it is a image or other file?