ImageIO - get image type and exif data

后端 未结 3 1751
天涯浪人
天涯浪人 2020-12-05 09:55

Given some source file (or more generic - input stream), I need to find out

  • is it an image
  • if it is an image, then retrieve its type (png/jpeg/gif/etc
3条回答
  •  情书的邮戳
    2020-12-05 10:42

    Easy answer: Use https://github.com/drewnoakes/metadata-extractor/

    If you're crazy/brave/curious, you could get image type from the stream by reading the first few bytes (these are magic numbers). I believe the exif is generally at the start of the stream too.

提交回复
热议问题