Skip to content

Commit

Permalink
Merge pull request #70 from plone/issue-68-branch42
Browse files Browse the repository at this point in the history
Do not fail image upload when Exif data is bad. [4.2]
  • Loading branch information
jensens authored Nov 8, 2018
2 parents e1fcfc0 + 2f553c5 commit d7163c4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions news/68.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Do not fail image upload when Exif data is bad. [maurits]
11 changes: 9 additions & 2 deletions plone/namedfile/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,15 @@ def __init__(self, data='', contentType='', filename=None):
'Exif Data: %s', exif_data)
orientation = exif_data['0th'].get(piexif.ImageIFD.Orientation, 1)
if 1 < orientation <= 8:
self.data, self._width, self._height, self.exif = rotate_image(
self.data)
try:
self.data, self._width, self._height, self.exif = \
rotate_image(self.data)
except KeyboardInterrupt:
raise
except Exception:
log.warning(
'Error rotating image %s based on exif data.',
filename, exc_info=1)
else:
self.exif = exif_data

Expand Down

2 comments on commit d7163c4

@jenkins-plone-org
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jensens Jenkins CI reporting about code analysis
See the full report here: https://jenkins.plone.org/job/package-plone.namedfile/120/violations

plone/namedfile/file.py:261:9: Q001 Remove bad quotes from multiline string.
plone/namedfile/file.py:302:9: Q001 Remove bad quotes from multiline string.
plone/namedfile/handler.py:11:23: C812 missing trailing comma
plone/namedfile/interfaces.py:17:25: C812 missing trailing comma
plone/namedfile/marshaler.py:67:36: C812 missing trailing comma
plone/namedfile/scaling.py:84:18: C812 missing trailing comma
plone/namedfile/scaling.py:200:25: C815 missing trailing comma in Python 3.5+
plone/namedfile/scaling.py:203:5: C901 'DefaultImageScalingFactory.__call__' is too complex (14)
plone/namedfile/scaling.py:210:25: C816 missing trailing comma in Python 3.6+
plone/namedfile/scaling.py:253:33: C815 missing trailing comma in Python 3.5+
plone/namedfile/scaling.py:407:21: C816 missing trailing comma in Python 3.6+
plone/namedfile/scaling.py:434:25: C815 missing trailing comma in Python 3.5+
plone/namedfile/scaling.py:446:25: C815 missing trailing comma in Python 3.5+
plone/namedfile/scaling.py:460:21: C816 missing trailing comma in Python 3.6+
plone/namedfile/scaling.py:486:29: C815 missing trailing comma in Python 3.5+
plone/namedfile/scaling.py:500:17: C816 missing trailing comma in Python 3.6+
plone/namedfile/testing.py:18:9: D001 found xmlconfig.file( replace it with self.loadZCML(
plone/namedfile/testing.py:22:36: C812 missing trailing comma
plone/namedfile/tests/test_blobfile.py:40:31: C812 missing trailing comma
plone/namedfile/tests/test_blobfile.py:45:35: C812 missing trailing comma
plone/namedfile/tests/test_blobfile.py:50:46: C812 missing trailing comma
plone/namedfile/tests/test_blobfile.py:55:32: C812 missing trailing comma
plone/namedfile/tests/test_doctests.py:25:51: C812 missing trailing comma
plone/namedfile/tests/test_doctests.py:27:10: C812 missing trailing comma
plone/namedfile/tests/test_scaling.py:86:40: C812 missing trailing comma
plone/namedfile/tests/test_scaling.py:105:40: C812 missing trailing comma
plone/namedfile/tests/test_scaling.py:138:40: C812 missing trailing comma
plone/namedfile/tests/test_scaling.py:163:40: C812 missing trailing comma
plone/namedfile/tests/test_scaling.py:187:40: C812 missing trailing comma
plone/namedfile/tests/test_scaling.py:211:40: C812 missing trailing comma
plone/namedfile/tests/test_scaling_functional.py:118:28: C812 missing trailing comma
plone/namedfile/tests/test_scaling_functional.py:148:70: C812 missing trailing comma
plone/namedfile/tests/test_scaling_functional.py:155:76: C812 missing trailing comma
plone/namedfile/tests/test_scaling_functional.py:166:74: C812 missing trailing comma
plone/namedfile/tests/test_scaling_functional.py:199:75: C812 missing trailing comma
plone/namedfile/tests/test_scaling_functional.py:204:78: C812 missing trailing comma
plone/namedfile/utils/__init__.py:84:66: C812 missing trailing comma
plone/namedfile/utils/__init__.py:153:15: T000 Todo note found.
plone/namedfile/utils/__init__.py:158:73: C812 missing trailing comma
plone/namedfile/utils/__init__.py:178:15: T000 Todo note found.
plone/namedfile/utils/__init__.py:185:18: C812 missing trailing comma
plone/namedfile/utils/__init__.py:190:1: C901 'rotate_image' is too complex (20)
plone/namedfile/utils/__init__.py:221:14: C812 missing trailing comma
plone/namedfile/utils/tiff_utils.py:12:1: C901 'process_tiff' is too complex (11)
plone/namedfile/utils/tiff_utils.py:21:7: T000 Todo note found.
plone/namedfile/utils/tiff_utils.py:82:7: T000 Todo note found.
plone/namedfile/utils/tiff_utils.py:83:7: T000 Todo note found.

Follow these instructions to reproduce it locally.

@jenkins-plone-org
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jensens Jenkins CI reporting about code analysis
See the full report here: https://jenkins.plone.org/job/package-plone.namedfile/121/violations

plone/namedfile/file.py:261:9: Q001 Remove bad quotes from multiline string.
plone/namedfile/file.py:302:9: Q001 Remove bad quotes from multiline string.
plone/namedfile/handler.py:11:23: C812 missing trailing comma
plone/namedfile/interfaces.py:17:25: C812 missing trailing comma
plone/namedfile/marshaler.py:67:36: C812 missing trailing comma
plone/namedfile/scaling.py:84:18: C812 missing trailing comma
plone/namedfile/scaling.py:200:25: C815 missing trailing comma in Python 3.5+
plone/namedfile/scaling.py:203:5: C901 'DefaultImageScalingFactory.__call__' is too complex (14)
plone/namedfile/scaling.py:210:25: C816 missing trailing comma in Python 3.6+
plone/namedfile/scaling.py:253:33: C815 missing trailing comma in Python 3.5+
plone/namedfile/scaling.py:407:21: C816 missing trailing comma in Python 3.6+
plone/namedfile/scaling.py:434:25: C815 missing trailing comma in Python 3.5+
plone/namedfile/scaling.py:446:25: C815 missing trailing comma in Python 3.5+
plone/namedfile/scaling.py:460:21: C816 missing trailing comma in Python 3.6+
plone/namedfile/scaling.py:486:29: C815 missing trailing comma in Python 3.5+
plone/namedfile/scaling.py:500:17: C816 missing trailing comma in Python 3.6+
plone/namedfile/testing.py:18:9: D001 found xmlconfig.file( replace it with self.loadZCML(
plone/namedfile/testing.py:22:36: C812 missing trailing comma
plone/namedfile/tests/test_blobfile.py:40:31: C812 missing trailing comma
plone/namedfile/tests/test_blobfile.py:45:35: C812 missing trailing comma
plone/namedfile/tests/test_blobfile.py:50:46: C812 missing trailing comma
plone/namedfile/tests/test_blobfile.py:55:32: C812 missing trailing comma
plone/namedfile/tests/test_doctests.py:25:51: C812 missing trailing comma
plone/namedfile/tests/test_doctests.py:27:10: C812 missing trailing comma
plone/namedfile/tests/test_scaling.py:86:40: C812 missing trailing comma
plone/namedfile/tests/test_scaling.py:105:40: C812 missing trailing comma
plone/namedfile/tests/test_scaling.py:138:40: C812 missing trailing comma
plone/namedfile/tests/test_scaling.py:163:40: C812 missing trailing comma
plone/namedfile/tests/test_scaling.py:187:40: C812 missing trailing comma
plone/namedfile/tests/test_scaling.py:211:40: C812 missing trailing comma
plone/namedfile/tests/test_scaling_functional.py:118:28: C812 missing trailing comma
plone/namedfile/tests/test_scaling_functional.py:148:70: C812 missing trailing comma
plone/namedfile/tests/test_scaling_functional.py:155:76: C812 missing trailing comma
plone/namedfile/tests/test_scaling_functional.py:166:74: C812 missing trailing comma
plone/namedfile/tests/test_scaling_functional.py:199:75: C812 missing trailing comma
plone/namedfile/tests/test_scaling_functional.py:204:78: C812 missing trailing comma
plone/namedfile/utils/__init__.py:84:66: C812 missing trailing comma
plone/namedfile/utils/__init__.py:153:15: T000 Todo note found.
plone/namedfile/utils/__init__.py:158:73: C812 missing trailing comma
plone/namedfile/utils/__init__.py:178:15: T000 Todo note found.
plone/namedfile/utils/__init__.py:185:18: C812 missing trailing comma
plone/namedfile/utils/__init__.py:190:1: C901 'rotate_image' is too complex (20)
plone/namedfile/utils/__init__.py:221:14: C812 missing trailing comma
plone/namedfile/utils/tiff_utils.py:12:1: C901 'process_tiff' is too complex (11)
plone/namedfile/utils/tiff_utils.py:21:7: T000 Todo note found.
plone/namedfile/utils/tiff_utils.py:82:7: T000 Todo note found.
plone/namedfile/utils/tiff_utils.py:83:7: T000 Todo note found.

Follow these instructions to reproduce it locally.

Please sign in to comment.