Skip to content

Commit 168d9cd

Browse files
authored
Fix #3785 — Ignore errors in parsing SVG files for shrinking them, copy original file to output instead (#3787)
1 parent 60ad869 commit 168d9cd

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

CHANGES.txt

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Features
77
Bugfixes
88
--------
99

10+
* Ignore errors in parsing SVG files for shrinking them, copy original file to output instead
11+
(Issue #3785)
1012
* Restore `annotation_helper.tmpl` with dummy content - fix themes still mentioning it
1113
(Issue #3764, #3773)
1214
* Fix compatibility with watchdog 4 (Issue #3766)

nikola/image_processing.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@
2828

2929
import datetime
3030
import gzip
31+
import logging
3132
import os
3233
import re
34+
import typing
3335

34-
import lxml
36+
import lxml.etree
3537
import piexif
3638
from PIL import ExifTags, Image
3739

@@ -43,6 +45,9 @@
4345
class ImageProcessor(object):
4446
"""Apply image operations."""
4547

48+
logger: logging.Logger
49+
dates: typing.Dict[str, datetime.datetime]
50+
4651
image_ext_list_builtin = ['.jpg', '.png', '.jpeg', '.gif', '.svg', '.svgz', '.bmp', '.tiff', '.webp']
4752

4853
def _fill_exif_tag_names(self):
@@ -211,6 +216,10 @@ def resize_svg(self, src, dst_paths, max_sizes, bigger_panoramas):
211216
except (KeyError, AttributeError) as e:
212217
self.logger.warning("No width/height in %s. Original exception: %s" % (src, e))
213218
utils.copy_file(src, dst)
219+
except Exception as e:
220+
self.logger.warning("Can't process {0}, using original "
221+
"image! ({1})".format(src, e))
222+
utils.copy_file(src, dst)
214223

215224
def image_date(self, src):
216225
"""Try to figure out the date of the image."""

0 commit comments

Comments
 (0)