-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
16 additions
and
230 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
def is_jpeg(data): | ||
jpeg_signature = b'\xFF\xD8\xFF' | ||
return data.startswith(jpeg_signature) | ||
|
||
def is_png(data): | ||
png_signature = b'\x89\x50\x4E\x47\x0D\x0A\x1A\x0A' | ||
return data.startswith(png_signature) | ||
|
||
|
||
def get_image_type_from_bytes(data): | ||
if is_jpeg(data): | ||
return "jpeg" | ||
elif is_png(data): | ||
return "png" | ||
else: | ||
raise ValueError("Image type not supported, only jpeg and png supported.") |
This file was deleted.
Oops, something went wrong.