Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #3785 — Ignore errors in parsing SVG files for shrinking them, copy original file to output instead #3787

Merged
merged 2 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading