Skip to content

Commit

Permalink
Fix staging broken
Browse files Browse the repository at this point in the history
  • Loading branch information
YayunHuang committed Aug 20, 2024
1 parent 2f87736 commit 58c4e64
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions mockup_package/mockup/image_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,21 @@ def create_fit_resolution_image(self):
# some picture has orientation property, which the browser knows and can automatically rotate the image # noqa: E501
# but the property is lost when we mockup the image, so need to fix it manually. # noqa: E501
# ref: https://stackoverflow.com/questions/13872331/rotating-an-image-with-orientation-specified-in-exif-using-python-without-pil-in # noqa: E501
for orientation in ExifTags.TAGS.keys():
if ExifTags.TAGS[orientation] == "Orientation":
break

exif = image.getexif()
if exif[orientation] == 3:
image = image.rotate(180, expand=True)
elif exif[orientation] == 6:
image = image.rotate(270, expand=True)
elif exif[orientation] == 8:
image = image.rotate(90, expand=True)
try:
for orientation in ExifTags.TAGS.keys():
if ExifTags.TAGS[orientation] == "Orientation":
break

exif = image.getexif()
if exif[orientation] == 3:
image = image.rotate(180, expand=True)
elif exif[orientation] == 6:
image = image.rotate(270, expand=True)
elif exif[orientation] == 8:
image = image.rotate(90, expand=True)
except Exception:
# image does not have orientation, expected case, will silent error
pass

find_original_image_dim_process = str(image.size[0]) + "x" + str(image.size[1])
original_image_dim = tuple(
Expand Down
Binary file modified public/mockup.zip
Binary file not shown.

0 comments on commit 58c4e64

Please sign in to comment.