diff --git a/features/image-generation.feature b/features/image-generation.feature index c9d511f..5e05c45 100644 --- a/features/image-generation.feature +++ b/features/image-generation.feature @@ -38,6 +38,18 @@ Feature: Responsive image generation And the file "assets/resized/subdir/test-100.png" should exist And the file "_site/assets/resized/subdir/test-100.png" should exist + Scenario: Honouring source image interlace mode + Given I have a responsive_image configuration with: + """ + template: _includes/responsive-image.html + sizes: + - width: 100 + """ + + And I have a file "index.html" with "{% responsive_image path: assets/progressive.jpeg %}" + When I run Jekyll + Then the image "assets/resized/progressive-100x50.jpeg" should be interlaced + Scenario: Honouring Jekyll 'source' configuration Given I have copied my site to "my-site-copy/src" And I have a configuration with: diff --git a/features/step_definitions/jekyll_steps.rb b/features/step_definitions/jekyll_steps.rb index ca86251..f89fc72 100644 --- a/features/step_definitions/jekyll_steps.rb +++ b/features/step_definitions/jekyll_steps.rb @@ -59,6 +59,12 @@ Then /^the image "(.+)" should have the dimensions "(\d+)x(\d+)"$/ do |path, wid img.destroy! end +Then /^the image "(.+)" should be interlaced$/ do |path| + img = Magick::Image::read(path).first + assert_equal Magick::JPEGInterlace, img.interlace + img.destroy! +end + def write_file(path, contents) File.open(path, 'w') do |f| f.write(contents) diff --git a/features/test-site/assets/progressive.jpeg b/features/test-site/assets/progressive.jpeg new file mode 100644 index 0000000..2c056c1 Binary files /dev/null and b/features/test-site/assets/progressive.jpeg differ diff --git a/lib/jekyll-responsive-image/resize_handler.rb b/lib/jekyll-responsive-image/resize_handler.rb index 1fc411f..319e916 100644 --- a/lib/jekyll-responsive-image/resize_handler.rb +++ b/lib/jekyll-responsive-image/resize_handler.rb @@ -30,6 +30,7 @@ module Jekyll i = img.scale(ratio) i.write(site_source_filepath) do |f| + f.interlace = i.interlace f.quality = size['quality'] || config['default_quality'] end