imogen 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/imogen/auto_crop.rb +1 -1
- data/lib/imogen/iiif/region.rb +2 -2
- data/lib/imogen/iiif.rb +2 -2
- data/lib/imogen.rb +2 -2
- data/spec/integration/imogen_autocrop_spec.rb +1 -0
- data/spec/integration/imogen_iiif_spec.rb +1 -0
- metadata +3 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: '09124ca98f369b44498c5605caa4f45dd5d8225b3416fb2bc4d90e7224a0fda2'
         | 
| 4 | 
            +
              data.tar.gz: e7e7b386740002d47365e5e1f1838c9328184982bcd90ca081405bf7f615bc6d
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: fddb3b745f8cca9c19e13e58f8d70f520e02a7319f4a46a4191497e47f70f1c5216ce500fe8e95a93b64207a83f1aaa15a889b67a0da507396143fef5aafef4f
         | 
| 7 | 
            +
              data.tar.gz: 67be3ab83b6823be1b662896085cc896a42c104bd99ea17d0f861dc1f1c1aa538e951fbc6f2aa2f2e13cbcc318d9defc2174bd8abae72d286b24b01261efb82f
         | 
    
        data/lib/imogen/auto_crop.rb
    CHANGED
    
    | @@ -2,7 +2,7 @@ module Imogen | |
| 2 2 | 
             
              module AutoCrop
         | 
| 3 3 | 
             
                def self.convert(img, dest_path, scale=768, opts = {})
         | 
| 4 4 | 
             
                  Imogen::Iiif::Region::Featured.convert(img, scale, opts) do |smartcrop|
         | 
| 5 | 
            -
                    smartcrop.write_to_file(dest_path)
         | 
| 5 | 
            +
                    smartcrop.write_to_file(dest_path, background: [255, 255, 255])
         | 
| 6 6 | 
             
                  end
         | 
| 7 7 | 
             
                end
         | 
| 8 8 | 
             
              end
         | 
    
        data/lib/imogen/iiif/region.rb
    CHANGED
    
    | @@ -63,7 +63,7 @@ class Region < Transform | |
| 63 63 | 
             
                  crop_scale = middle_dims.min
         | 
| 64 64 | 
             
                  smart_crop_opts = {interesting: (squarish?(img) ? :centre : :entropy)}.merge(opts)
         | 
| 65 65 | 
             
                  window = img.extract_area(x_offset, y_offset, middle_dims[0], middle_dims[1])
         | 
| 66 | 
            -
                  smartcrop = window.smartcrop(crop_scale, crop_scale, smart_crop_opts)
         | 
| 66 | 
            +
                  smartcrop = window.smartcrop(crop_scale, crop_scale, **smart_crop_opts)
         | 
| 67 67 | 
             
                  # Vips counts with negative offsets from left and top
         | 
| 68 68 | 
             
                  yield smartcrop.thumbnail_image(scale, height: scale)
         | 
| 69 69 | 
             
                end
         | 
| @@ -76,7 +76,7 @@ class Region < Transform | |
| 76 76 | 
             
                  crop_scale = middle_dims.min
         | 
| 77 77 | 
             
                  smart_crop_opts = {interesting: (squarish?(img) ? :centre : :entropy)}.merge(opts)
         | 
| 78 78 | 
             
                  window = img.extract_area(x_offset, y_offset, middle_dims[0], middle_dims[1])
         | 
| 79 | 
            -
                  smartcrop = window.smartcrop(crop_scale, crop_scale, smart_crop_opts)
         | 
| 79 | 
            +
                  smartcrop = window.smartcrop(crop_scale, crop_scale, **smart_crop_opts)
         | 
| 80 80 | 
             
                  # Vips counts with negative offsets from left and top
         | 
| 81 81 | 
             
                  left = (window.xoffset + smartcrop.xoffset)*-1
         | 
| 82 82 | 
             
                  top = (window.yoffset + smartcrop.yoffset)*-1
         | 
    
        data/lib/imogen/iiif.rb
    CHANGED
    
    | @@ -53,7 +53,7 @@ module Imogen | |
| 53 53 | 
             
                    Size.convert(region, opts[:size]) do |size|
         | 
| 54 54 | 
             
                      Rotation.convert(size, opts[:rotation]) do |rotation|
         | 
| 55 55 | 
             
                        Quality.convert(rotation, opts[:quality]) do |quality|
         | 
| 56 | 
            -
                          quality.write_to_file(dest_path)
         | 
| 56 | 
            +
                          quality.write_to_file(dest_path, background: [255, 255, 255])
         | 
| 57 57 | 
             
                          yield quality if block_given?
         | 
| 58 58 | 
             
                        end
         | 
| 59 59 | 
             
                      end
         | 
| @@ -77,4 +77,4 @@ module Imogen | |
| 77 77 | 
             
                  }
         | 
| 78 78 | 
             
                end
         | 
| 79 79 | 
             
              end
         | 
| 80 | 
            -
            end
         | 
| 80 | 
            +
            end
         | 
    
        data/lib/imogen.rb
    CHANGED
    
    | @@ -10,12 +10,12 @@ module Imogen | |
| 10 10 | 
             
                  w = img.width
         | 
| 11 11 | 
             
                  h = img.height
         | 
| 12 12 | 
             
                  dims = (w > h) ? [scale, scale*h/w] : [scale*w/h, scale]
         | 
| 13 | 
            -
                  img.thumbnail_image(dims[0], height: dims[1]).write_to_file(dest_path)
         | 
| 13 | 
            +
                  img.thumbnail_image(dims[0], height: dims[1]).write_to_file(dest_path, background: [255, 255, 255])
         | 
| 14 14 | 
             
                end
         | 
| 15 15 | 
             
              end
         | 
| 16 16 | 
             
              module Cropped
         | 
| 17 17 | 
             
                def self.convert(img, dest_path, edges, scale=nil, format=:jpeg)
         | 
| 18 | 
            -
                  img.crop(*edges).write_to_file(dest_path)
         | 
| 18 | 
            +
                  img.crop(*edges).write_to_file(dest_path, background: [255, 255, 255])
         | 
| 19 19 | 
             
                end
         | 
| 20 20 | 
             
              end
         | 
| 21 21 | 
             
              require 'imogen/auto_crop'
         | 
| @@ -5,6 +5,7 @@ describe Imogen::AutoCrop, vips: true do | |
| 5 5 | 
             
              describe "#convert" do
         | 
| 6 6 | 
             
                let(:output_file) { Dir.tmpdir + '/test-imogen-crop.jpg' }
         | 
| 7 7 | 
             
                it "should successfully convert the image" do
         | 
| 8 | 
            +
                  expect_any_instance_of(Vips::Image).to receive(:write_to_file).with(String, {background: [255, 255, 255]}).and_call_original
         | 
| 8 9 | 
             
                  Imogen.with_image(fixture('sample.jpg').path) do |img|
         | 
| 9 10 | 
             
                    Imogen::AutoCrop.convert(img, output_file, 150)
         | 
| 10 11 | 
             
                  end
         | 
| @@ -5,6 +5,7 @@ describe Imogen::AutoCrop, vips: true do | |
| 5 5 | 
             
              describe "#convert" do
         | 
| 6 6 | 
             
                let(:output_file) { Dir.tmpdir + '/test-imogen-convert.jpg' }
         | 
| 7 7 | 
             
                it "should successfully convert the image" do
         | 
| 8 | 
            +
                  expect_any_instance_of(Vips::Image).to receive(:write_to_file).with(String, {background: [255, 255, 255]}).and_call_original
         | 
| 8 9 | 
             
                  Imogen.with_image(fixture('sample.jpg').path) do |img|
         | 
| 9 10 | 
             
                    Imogen::Iiif.convert(img, output_file, 'jpg', region: '50,60,500,800', size: '!100,100', quality: 'color', rotation: '!90')
         | 
| 10 11 | 
             
                  end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: imogen
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.3.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Ben Armintor
         | 
| @@ -9,7 +9,7 @@ authors: | |
| 9 9 | 
             
            autorequire:
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date:  | 
| 12 | 
            +
            date: 2022-12-09 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: ruby-vips
         | 
| @@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 96 96 | 
             
                - !ruby/object:Gem::Version
         | 
| 97 97 | 
             
                  version: '0'
         | 
| 98 98 | 
             
            requirements: []
         | 
| 99 | 
            -
            rubygems_version: 3. | 
| 99 | 
            +
            rubygems_version: 3.1.6
         | 
| 100 100 | 
             
            signing_key:
         | 
| 101 101 | 
             
            specification_version: 4
         | 
| 102 102 | 
             
            summary: IIIF image derivative generation helpers for Vips
         |