How to check if an image file is JPEG 2000
in Python?
If possible, without installing a heavy image library.
How to check if an image file is JPEG 2000
in Python?
If possible, without installing a heavy image library.
Copyright © 2021 Jogjafile Inc.
If the image is stored as a file, you can check if it starts with the JPEG 2000 magic number,
00 00 00 0C 6A 50 20 20 0D 0A 87 0A
orFF 4F FF 51
. Just like this:If the image is not stored as a file, then you can easily adapt this code. All you need to do is check if the first 12 or 4 bytes match the magic number.