Created
January 5, 2024 02:19
-
-
Save simryang/7aafa6deba3f616533d744336d5919c2 to your computer and use it in GitHub Desktop.
check a file is jpg or not
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pathlib import Path | |
def is_jpg(): | |
img = Path("output-2023-12-15/30661_10000000c840e868_2023-12-15_16-01-46.wav").read_bytes() | |
print("jpg" if img[0] == 0xff and img[1] == 0xd8 and img[2] == 0xff else "no jpg") | |
return True if img[0] == 0xff and img[1] == 0xd8 and img[2] == 0xff else False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment