-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add new module isValidImage 0.1.0v
- Loading branch information
1 parent
d0fe80d
commit 2b7144b
Showing
4 changed files
with
38 additions
and
3 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
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,8 @@ | ||
def isValidImage(file_buffer): | ||
# Check the magic numbers to determine the mimetype | ||
is_jpeg = file_buffer[0] == 0xff and file_buffer[1] == 0xd8 and file_buffer[2] == 0xff | ||
is_png = file_buffer[0] == 0x89 and file_buffer[1] == 0x50 and file_buffer[2] == 0x4e and file_buffer[3] == 0x47 | ||
is_gif = file_buffer[0] == 0x47 and file_buffer[1] == 0x49 and file_buffer[2] == 0x46 and file_buffer[3] == 0x38 | ||
|
||
return is_jpeg or is_png or is_gif | ||
|