morandi 0.11.0 → 0.11.1

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: 68cd42331964c9dd3672616161db84d71093f565f0186c4cc1b090bfec537cab
4
- data.tar.gz: 3715b3e1b8288453ea1421260ca8a6305867305b1047e8ffa855c82b4b5fc501
3
+ metadata.gz: 9cc53b714e3e5e997376714b0f5033b14c753110b82a2d2de2b0d2d90b173b14
4
+ data.tar.gz: 4d59da477a6760c96c227d4b1d416b5114086ff63986c4631e9e406e73b4ec3e
5
5
  SHA512:
6
- metadata.gz: b1af52f959e8b6dc5c25dadb1368797943d5d68256386b3f41be57ed4d1c92c1091977f00982ca1f3169b82df71f75dcd64d8a7346f4eb03f1fdc939df98856c
7
- data.tar.gz: c8831c9ad0fc69f433abddbacc15352dfca2ad156841167f942038536cfcabf243d659967b1b64f865d6280797a0dcf2866e1f46695ef4c8e99db333cc700909
6
+ metadata.gz: b12fa0320ca0dd1d036fe2d84fbf7948b6020c0a90d2db75a13b3b8b33c38b6aa9b6ceb9fe5caa0e6b1deace48012c9748e44cd3b455a5af9afc9662e16446ad
7
+ data.tar.gz: 5695162218181fe2adc94e4d851411079e1703b2238a424330f5b80725e18e4fbe58bb669d92b377aa32e930754a7bd157b8f28a8d0cd595eb0b0515d3f3487b
data/.gitignore CHANGED
@@ -1,6 +1,7 @@
1
1
  *.gem
2
2
  *.rbc
3
3
  .bundle
4
+ .DS_Store
4
5
  .config
5
6
  .yardoc
6
7
  Gemfile.lock
data/CHANGELOG.md CHANGED
@@ -9,3 +9,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
9
9
  ## [0.11.0] 07.12.2018
10
10
  ### Added
11
11
  - Added option to set the JPEG image compression size [104324]
12
+
13
+ ## [0.11.1] 21.02.2019
14
+ ### Added
15
+ - Have option to set the JPEG image compression size be a string like all the other options. [TECH-7701]
16
+ - While throwing Gdk::PixbufError::CorruptImage in Morandi::ProfiledPixbuf#initialize try to recover the image by saving it to a tempfile and re-read. This operation should remove all wrong markers. [TECH-7663]
@@ -72,7 +72,7 @@ class Morandi::ImageProcessor
72
72
  end
73
73
 
74
74
  def write_to_jpeg(fn, quality = nil)
75
- quality ||= options.fetch(:quality, 97)
75
+ quality ||= options.fetch('quality', 97)
76
76
  @pb.save(fn, 'jpeg', quality: quality)
77
77
  end
78
78
 
@@ -12,6 +12,15 @@ class Morandi::ProfiledPixbuf < Gdk::Pixbuf
12
12
  false
13
13
  end
14
14
 
15
+ def self.from_string(string, loader: nil, chunk_size: 4096)
16
+ loader ||= Gdk::PixbufLoader.new
17
+ ((string.bytesize + chunk_size - 1) / chunk_size).times do |i|
18
+ loader.write(string.byteslice(i * chunk_size, chunk_size))
19
+ end
20
+ loader.close
21
+ loader.pixbuf
22
+ end
23
+
15
24
  def self.default_icc_path(path)
16
25
  "#{path}.icc.jpg"
17
26
  end
@@ -30,6 +39,18 @@ class Morandi::ProfiledPixbuf < Gdk::Pixbuf
30
39
  end
31
40
 
32
41
  super(*args)
42
+ rescue Gdk::PixbufError::CorruptImage => e
43
+ if args[0].is_a?(String) && defined? Tempfile
44
+ temp = Tempfile.new
45
+ pixbuf = self.class.from_string(File.read(args[0]))
46
+ pixbuf.save(temp.path, 'jpeg')
47
+ args[0] = temp.path
48
+ super(*args)
49
+ temp.close
50
+ temp.unlink
51
+ else
52
+ throw e
53
+ end
33
54
  end
34
55
 
35
56
 
@@ -1,3 +1,3 @@
1
1
  module Morandi
2
- VERSION = '0.11.0'.freeze
2
+ VERSION = '0.11.1'.freeze
3
3
  end
data/spec/morandi_spec.rb CHANGED
@@ -122,7 +122,7 @@ RSpec.describe Morandi, "#process" do
122
122
 
123
123
  context 'with increasing quality settings' do
124
124
  let(:max_quality_file_size) do
125
- Morandi.process("sample/sample.jpg", { quality: 100 }, "sample/out-100.jpg")
125
+ Morandi.process("sample/sample.jpg", { 'quality' => 100 }, "sample/out-100.jpg")
126
126
  File.size("sample/out-100.jpg")
127
127
  end
128
128
 
@@ -132,7 +132,7 @@ RSpec.describe Morandi, "#process" do
132
132
  end
133
133
 
134
134
  let(:quality_of_40_by_options_args) do
135
- Morandi.process("sample/sample.jpg", { quality: 40 }, "sample/out-40.jpg")
135
+ Morandi.process("sample/sample.jpg", { 'quality' => 40 }, "sample/out-40.jpg")
136
136
  File.size("sample/out-40.jpg")
137
137
  end
138
138
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: morandi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - |+
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2018-12-13 00:00:00.000000000 Z
14
+ date: 2019-02-22 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: gtk2