Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.io.base
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
Package registry
Model registry
Operate
Environments
Terraform modules
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
Show more breadcrumbs
bob
bob.io.base
Commits
b79083a9
Commit
b79083a9
authored
3 years ago
by
Tiago de Freitas Pereira
Browse files
Options
Downloads
Patches
Plain Diff
Truncated jpeg test case
parent
8ce63866
No related branches found
No related tags found
1 merge request
!36
new image and hdf5 support
Pipeline
#60444
passed
3 years ago
Stage: build
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
bob/io/base/__init__.py
+8
-2
8 additions, 2 deletions
bob/io/base/__init__.py
bob/io/base/test/data/truncated_jpeg.jpg
+0
-0
0 additions, 0 deletions
bob/io/base/test/data/truncated_jpeg.jpg
bob/io/base/test/test_image_support.py
+5
-1
5 additions, 1 deletion
bob/io/base/test/test_image_support.py
with
13 additions
and
3 deletions
bob/io/base/__init__.py
+
8
−
2
View file @
b79083a9
...
...
@@ -2,6 +2,7 @@
import
numpy
as
np
import
h5py
import
imageio
from
.utils
import
to_bob
,
to_matplotlib
,
opencvbgr_to_bob
,
bob_to_opencvbgr
,
imshow
import
logging
...
...
@@ -9,6 +10,12 @@ import logging
logger
=
logging
.
getLogger
(
__name__
)
import
os
# Allowing the loading of truncated files in case PIL is used
# https://github.com/kirumang/Pix2Pose/issues/2
from
PIL
import
ImageFile
ImageFile
.
LOAD_TRUNCATED_IMAGES
=
True
hdf5_extensions
=
[
"
.hdf5
"
,
"
.h5
"
,
"
.hdf
"
,
"
.hdf5
"
,
"
.h5
"
,
"
.hdf
"
,
"
.hdf5
"
]
image_extensions
=
[
...
...
@@ -86,7 +93,6 @@ def open_file(filename):
return
img
extension
=
os
.
path
.
splitext
(
filename
)[
1
]
# get the extension
# logger.error("############")
# logger.error(filename)
if
extension
in
hdf5_extensions
:
...
...
@@ -141,7 +147,7 @@ def write_file(filename, data, format="pillow"):
f
[
"
array
"
]
=
data
elif
extension
in
image_extensions
:
# Pillow is the format with the best support for all image formats
imageio
.
imwrite
(
filename
,
data
,
format
=
format
)
imageio
.
imwrite
(
filename
,
to_matplotlib
(
data
)
,
format
=
format
)
else
:
raise
RuntimeError
(
f
"
Unknown file extension:
{
extension
}
"
)
...
...
This diff is collapsed.
Click to expand it.
bob/io/base/test/data/truncated_jpeg.jpg
0 → 100755
+
0
−
0
View file @
b79083a9
2.73 MiB
This diff is collapsed.
Click to expand it.
bob/io/base/test/test_image_support.py
+
5
−
1
View file @
b79083a9
...
...
@@ -155,5 +155,9 @@ def test_image_load():
def
test_image_exceptions
():
# This tests some image exceptions I found
# Real PNG image
# Real
GRAY
PNG image
transcode
(
datafile
(
"
read_png_gray.png
"
,
__name__
))
# Trucated JPEG
# THIS TEST FAILS
# transcode(datafile("truncated_jpeg.jpg", __name__))
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