From 82e868966c18c170d96199c78657c5092cf4a54d Mon Sep 17 00:00:00 2001 From: Daniel Pietzsch Date: Sun, 8 Nov 2020 21:43:29 +0100 Subject: [PATCH] Making sure full image is loaded when auto_rotate config option is used MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit because then we need the full image right at the start – as before – and there's no need to load "properties only" first, to then load the full image right after. --- lib/jekyll-responsive-image/resize_handler.rb | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/jekyll-responsive-image/resize_handler.rb b/lib/jekyll-responsive-image/resize_handler.rb index f373f92..21dbbd3 100644 --- a/lib/jekyll-responsive-image/resize_handler.rb +++ b/lib/jekyll-responsive-image/resize_handler.rb @@ -6,18 +6,19 @@ module Jekyll attr_reader :original_image def initialize(original_image_absolute_path, config) - @original_image_absolute_path = original_image_absolute_path - @original_image = Magick::Image::ping(original_image_absolute_path).first - @original_image_pixels_loaded = false @config = config - end - def resize_image + @original_image_absolute_path = original_image_absolute_path + if @config['auto_rotate'] load_full_image @original_image.auto_orient! + else + load_image_properties_only end + end + def resize_image resized = [] @config['sizes'].each do |size| @@ -92,6 +93,11 @@ module Jekyll @original_image_pixels_loaded = true end + def load_image_properties_only + @original_image = Magick::Image::ping(@original_image_absolute_path).first + @original_image_pixels_loaded = false + end + def ensure_output_dir_exists!(path) dir = File.dirname(path)