From 5c0d4028d3e6e04769ab7bb68258c02cd4769406 Mon Sep 17 00:00:00 2001 From: jnguiot <45011516+jnguiot@users.noreply.github.com> Date: Tue, 1 Feb 2022 21:48:24 +0100 Subject: [PATCH 1/5] Add compat for itsdangerous 2.0+ --- flask_images/core.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/flask_images/core.py b/flask_images/core.py index d299902..8682604 100755 --- a/flask_images/core.py +++ b/flask_images/core.py @@ -27,11 +27,12 @@ from PIL import Image, ImageFilter from flask import request, current_app, send_file, abort +from hmac import compare_digest as constant_time_compare + try: - from itsdangerous import Signer, constant_time_compare + from itsdangerous import Signer except ImportError: from itsdangerous import Signer - from itsdangerous._compat import constant_time_compare from . import modes from .size import ImageSize From 4562f7b599de439c9362ec7edc1ec31de72c58ad Mon Sep 17 00:00:00 2001 From: jnguiot <45011516+jnguiot@users.noreply.github.com> Date: Tue, 1 Feb 2022 22:25:58 +0100 Subject: [PATCH 2/5] Remove usage of ssh to get submodule --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 9ae102d..fd3f7c4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "docs/_themes"] path = docs/_themes - url = git@github.com:mitsuhiko/flask-sphinx-themes.git + url = https://github.com/pallets/flask-sphinx-themes.git From 8049b0ed2524f75020297a7a539c0028751cec4e Mon Sep 17 00:00:00 2001 From: jnguiot <45011516+jnguiot@users.noreply.github.com> Date: Sat, 24 Sep 2022 17:27:04 +0200 Subject: [PATCH 3/5] Fix #64: compatibility with Flask 2.2.0+ --- flask_images/core.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/flask_images/core.py b/flask_images/core.py index 8682604..16a4cb4 100755 --- a/flask_images/core.py +++ b/flask_images/core.py @@ -429,7 +429,7 @@ def handle_request(self, path): image.save(cache_file, format, quality=quality) cache_file.close() - return send_file(cache_path, mimetype=mimetype, cache_timeout=cache_timeout) + return send_file(cache_path, mimetype=mimetype, max_age=cache_timeout) diff --git a/setup.py b/setup.py index 453a02f..ebbe653 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name='Flask-Images', - version='3.0.2', + version='3.0.3', description='Dynamic image resizing for Flask.', url='http://github.com/mikeboers/Flask-Images', From a026a9e4d97ff37e94dceb5b6a2777627c386cf9 Mon Sep 17 00:00:00 2001 From: gdaviet <57617656+gdaviet@users.noreply.github.com> Date: Wed, 16 Nov 2022 07:54:10 +0100 Subject: [PATCH 4/5] Make mtime naive or offset-aware depending on if_modifed_since Make mtime naive or offset-aware depending on if_modifed_since --- CHANGELOG.txt | 8 ++++++++ flask_images/core.py | 8 +++++--- setup.py | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 68c466c..34ad726 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,4 +1,12 @@ +3.0.4 +----- +- Fix comparison between offset-aware and naive datetimes + +3.0.3 +----- +- Fix compatibility with itsdangerous 2.0+ + 3.0.2 ----- - Fix a couple Python3 dict API changes. diff --git a/flask_images/core.py b/flask_images/core.py index 16a4cb4..ccf52b6 100755 --- a/flask_images/core.py +++ b/flask_images/core.py @@ -351,11 +351,13 @@ def handle_request(self, path): abort(404) # Not found. raw_mtime = os.path.getmtime(path) - mtime = datetime.datetime.utcfromtimestamp(raw_mtime).replace(microsecond=0) # log.debug('last_modified: %r' % mtime) # log.debug('if_modified_since: %r' % request.if_modified_since) - if request.if_modified_since and request.if_modified_since >= mtime: - return '', 304 + if request.if_modified_since: + tzinfo = request.if_modified_since.tzinfo + mtime = datetime.datetime.fromtimestamp(raw_mtime, tz=tzinfo).replace(microsecond=0) + if request.if_modified_since >= mtime: + return '', 304 mode = query.get('mode') diff --git a/setup.py b/setup.py index ebbe653..ec51f41 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name='Flask-Images', - version='3.0.3', + version='3.0.4', description='Dynamic image resizing for Flask.', url='http://github.com/mikeboers/Flask-Images', From 4636afc4547049d27dfc76f8ce8fecb74c1f1a97 Mon Sep 17 00:00:00 2001 From: Gilles Daviet Date: Sun, 19 Nov 2023 09:15:44 +0100 Subject: [PATCH 5/5] Fix for new PIL --- flask_images/core.py | 4 ++-- setup.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/flask_images/core.py b/flask_images/core.py index ccf52b6..487c33b 100755 --- a/flask_images/core.py +++ b/flask_images/core.py @@ -256,13 +256,13 @@ def resize(self, image, background=None, **kw): # Handle the easy cases. if size.mode in (modes.RESHAPE, None) or size.req_width is None or size.req_height is None: - return image.resize((size.width, size.height), Image.ANTIALIAS) + return image.resize((size.width, size.height), Image.LANCZOS) if size.mode not in (modes.FIT, modes.PAD, modes.CROP): raise ValueError('unknown mode %r' % size.mode) if image.size != (size.op_width, size.op_height): - image = image.resize((size.op_width, size.op_height), Image.ANTIALIAS) + image = image.resize((size.op_width, size.op_height), Image.LANCZOS) if size.mode == modes.FIT: return image diff --git a/setup.py b/setup.py index ec51f41..01b86d2 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name='Flask-Images', - version='3.0.4', + version='3.0.5', description='Dynamic image resizing for Flask.', url='http://github.com/mikeboers/Flask-Images',