mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-10-06 17:31:07 +03:00
update: log errors on bad graphics, and then ignore the file
Python PIL is not so tolerant, so bad EXIF causes crashes: File "/var/lib/jenkins/userContent/reproducible/reproducible_fdroid_build_apps/fdroidserver/update.py", line 2088, in main insert_localized_app_metadata(apps) File "/var/lib/jenkins/userContent/reproducible/reproducible_fdroid_build_apps/fdroidserver/update.py", line 978, in insert_localized_app_metadata _strip_and_copy_image(os.path.join(root, f), destdir) File "/var/lib/jenkins/userContent/reproducible/reproducible_fdroid_build_apps/fdroidserver/update.py", line 754, in _strip_and_copy_image in_image = Image.open(fp) File "/usr/lib/python3/dist-packages/PIL/Image.py", line 2687, in open % (filename if filename else fp)) OSError: cannot identify image file <_io.BufferedReader name='build/org.sw24softwares.starkeverben/fastlane/metadata/android/en-US/images/featureGraphic.png'>
This commit is contained in:
parent
c738ad54ec
commit
c7048f2c39
3 changed files with 34 additions and 10 deletions
|
@ -733,6 +733,8 @@ def _strip_and_copy_image(in_file, outpath):
|
|||
outpath can be path to either a file or dir. The dir that outpath
|
||||
refers to must exist before calling this.
|
||||
|
||||
Potential source of Python code to strip JPEGs without dependencies:
|
||||
http://www.fetidcascade.com/public/minimal_exif_writer.py
|
||||
"""
|
||||
logging.debug('copying ' + in_file + ' ' + outpath)
|
||||
|
||||
|
@ -750,17 +752,25 @@ def _strip_and_copy_image(in_file, outpath):
|
|||
|
||||
extension = common.get_extension(in_file)[1]
|
||||
if extension == 'png':
|
||||
with open(in_file, 'rb') as fp:
|
||||
in_image = Image.open(fp)
|
||||
in_image.save(out_file, "PNG", optimize=True,
|
||||
pnginfo=BLANK_PNG_INFO, icc_profile=None)
|
||||
try:
|
||||
with open(in_file, 'rb') as fp:
|
||||
in_image = Image.open(fp)
|
||||
in_image.save(out_file, "PNG", optimize=True,
|
||||
pnginfo=BLANK_PNG_INFO, icc_profile=None)
|
||||
except Exception as e:
|
||||
logging.error(_("Failed copying {path}: {error}".format(path=in_file, error=e)))
|
||||
return
|
||||
elif extension == 'jpg' or extension == 'jpeg':
|
||||
with open(in_file, 'rb') as fp:
|
||||
in_image = Image.open(fp)
|
||||
data = list(in_image.getdata())
|
||||
out_image = Image.new(in_image.mode, in_image.size)
|
||||
out_image.putdata(data)
|
||||
out_image.save(out_file, "JPEG", optimize=True)
|
||||
try:
|
||||
with open(in_file, 'rb') as fp:
|
||||
in_image = Image.open(fp)
|
||||
data = list(in_image.getdata())
|
||||
out_image = Image.new(in_image.mode, in_image.size)
|
||||
out_image.putdata(data)
|
||||
out_image.save(out_file, "JPEG", optimize=True)
|
||||
except Exception as e:
|
||||
logging.error(_("Failed copying {path}: {error}".format(path=in_file, error=e)))
|
||||
return
|
||||
else:
|
||||
raise FDroidException(_('Unsupported file type "{extension}" for repo graphic')
|
||||
.format(extension=extension))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue