Skip to content

Instantly share code, notes, and snippets.

@simryang
Created January 5, 2024 02:19
Show Gist options
  • Save simryang/7aafa6deba3f616533d744336d5919c2 to your computer and use it in GitHub Desktop.
Save simryang/7aafa6deba3f616533d744336d5919c2 to your computer and use it in GitHub Desktop.
check a file is jpg or not
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