-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move the utilities from __init__ to a new file
- Loading branch information
Showing
4 changed files
with
19 additions
and
20 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
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
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 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