imogen 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 92c92a32465d8ae59f5e40a31c0ffd3cc2de271a3593db0dac7da1bd2954dd31
4
- data.tar.gz: 044b86d16c8c028d36864e3aa550b6aa871d9075c5d4223b198ca1ac59b511f2
3
+ metadata.gz: '09124ca98f369b44498c5605caa4f45dd5d8225b3416fb2bc4d90e7224a0fda2'
4
+ data.tar.gz: e7e7b386740002d47365e5e1f1838c9328184982bcd90ca081405bf7f615bc6d
5
5
  SHA512:
6
- metadata.gz: dc4ae61808bb12ad97f4f3a279aa81fd048b20626422358ccfc64ed1c5706d221a97195a0807dcd882c32dbfbd8ced6fba06bfe9e361ae61abfd6a1a38aed5a2
7
- data.tar.gz: d416dd8390d144135bf5d1e4d9dc5445d0f137a6e64ce097aef8fe2e5f895214a18a4f5fd064f874ead2928db969b5dbc92fbe5a86ac20c244e199c6bca93757
6
+ metadata.gz: fddb3b745f8cca9c19e13e58f8d70f520e02a7319f4a46a4191497e47f70f1c5216ce500fe8e95a93b64207a83f1aaa15a889b67a0da507396143fef5aafef4f
7
+ data.tar.gz: 67be3ab83b6823be1b662896085cc896a42c104bd99ea17d0f861dc1f1c1aa538e951fbc6f2aa2f2e13cbcc318d9defc2174bd8abae72d286b24b01261efb82f
@@ -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
@@ -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.2.1
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: 2021-02-26 00:00:00.000000000 Z
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.0.8
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