Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.io.image
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
bob
bob.io.image
Commits
626b22ae
Commit
626b22ae
authored
8 years ago
by
Manuel Günther
Browse files
Options
Downloads
Patches
Plain Diff
Hot-fixed weired imghdr issue with identfying jpegs
parent
c3c2c9e9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/io/image/__init__.py
+10
-2
10 additions, 2 deletions
bob/io/image/__init__.py
with
10 additions
and
2 deletions
bob/io/image/__init__.py
+
10
−
2
View file @
626b22ae
...
...
@@ -17,6 +17,12 @@ def get_config():
import
bob.extension
return
bob
.
extension
.
get_config
(
__name__
,
version
.
externals
)
# fix imghdr's jpeg detection to use the first two bytes (according to https://en.wikipedia.org/wiki/List_of_file_signatures)
import
imghdr
def
_test_jpeg
(
h
,
f
):
if
h
.
startswith
(
'
\xff\xd8
'
):
return
"
jpeg
"
imghdr
.
tests
.
append
(
_test_jpeg
)
def
load
(
filename
,
extension
=
None
):
"""
load(filename) -> image
...
...
@@ -48,8 +54,10 @@ def load(filename, extension=None):
f
=
bob
.
io
.
base
.
File
(
filename
,
'
r
'
)
else
:
if
extension
==
'
auto
'
:
import
imghdr
extension
=
"
.
"
+
imghdr
.
what
(
filename
)
extension
=
imghdr
.
what
(
filename
)
if
extension
is
None
:
raise
IOError
(
"
Could not detect the image type of file %s
"
%
filename
)
extension
=
"
.
"
+
extension
f
=
bob
.
io
.
base
.
File
(
filename
,
'
r
'
,
extension
)
return
f
.
read
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment