Skip to content

Commit

Permalink
Fix #3785 — Ignore errors in parsing SVG files for shrinking them, co…
Browse files Browse the repository at this point in the history
…py original file to output instead (#3787)
  • Loading branch information
Kwpolska authored Aug 28, 2024
1 parent 60ad869 commit 168d9cd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Features
Bugfixes
--------

* Ignore errors in parsing SVG files for shrinking them, copy original file to output instead
(Issue #3785)
* Restore `annotation_helper.tmpl` with dummy content - fix themes still mentioning it
(Issue #3764, #3773)
* Fix compatibility with watchdog 4 (Issue #3766)
Expand Down
11 changes: 10 additions & 1 deletion nikola/image_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@

import datetime
import gzip
import logging
import os
import re
import typing

import lxml
import lxml.etree
import piexif
from PIL import ExifTags, Image

Expand All @@ -43,6 +45,9 @@
class ImageProcessor(object):
"""Apply image operations."""

logger: logging.Logger
dates: typing.Dict[str, datetime.datetime]

image_ext_list_builtin = ['.jpg', '.png', '.jpeg', '.gif', '.svg', '.svgz', '.bmp', '.tiff', '.webp']

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

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

0 comments on commit 168d9cd

Please sign in to comment.