image_quality_check 0.3.0 → 0.4.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c34b97bb325493a6e00fa5edfbab4e0187230f3ce9271681d16085f3da4ecb3
|
4
|
+
data.tar.gz: 4cdab0adfd1efab3a287a1f45649abe2e3303f00dd661665ef13747eea2d743e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0eb0945139a77528a4910ff499ffbea9b1a63c996078ed9b740dd31ddf5b5c67094a10f348ee96574e86b3b83bdf1a3142b9fca86c6dc5fb4ee653454a8780cc
|
7
|
+
data.tar.gz: fcde5e2077d891ae333ff397ad561cbd0cd7df639670bb9ee541a7564eab05b40d625526235747bdab2b232dad705e12c6eb5de82d5791ee85dc29bab82238e5
|
@@ -70,7 +70,10 @@ class ImageQualityCheck::DetermineQuality
|
|
70
70
|
true
|
71
71
|
end
|
72
72
|
when "Paperclip::Attachment"
|
73
|
-
if
|
73
|
+
if @column.options[:storage] == :s3
|
74
|
+
@column.copy_to_local_file(:original, tmp_file.path)
|
75
|
+
true
|
76
|
+
elsif !@column.path || !File.exist?(@column.path)
|
74
77
|
false
|
75
78
|
else
|
76
79
|
FileUtils.cp(@column.path, tmp_file.path)
|
data/lib/image_quality_check.rb
CHANGED
@@ -14,12 +14,18 @@ module ImageQualityCheck
|
|
14
14
|
|
15
15
|
def self.analyze(path_to_image)
|
16
16
|
out = `convert #{Shellwords.escape path_to_image} json:`
|
17
|
-
# image magick gif delay bug invalid json
|
18
|
-
# https://github.com/ImageMagick/ImageMagick/issues/1624
|
19
|
-
out.gsub!(/("delay": "[^"]+")\n/m, "\\1,\n")
|
20
17
|
return {} if out.empty?
|
21
18
|
|
22
|
-
raw_json =
|
19
|
+
raw_json = nil
|
20
|
+
begin
|
21
|
+
raw_json = JSON.parse(out)
|
22
|
+
rescue StandardError
|
23
|
+
# image magick gif delay bug invalid json
|
24
|
+
# https://github.com/ImageMagick/ImageMagick/issues/1624
|
25
|
+
out.gsub!(/("delay": "[^"]+")\n/m, "\\1,\n")
|
26
|
+
end
|
27
|
+
|
28
|
+
raw_json ||= JSON.parse(out)
|
23
29
|
json = raw_json.is_a?(Array) ? raw_json.first['image'] : raw_json['image']
|
24
30
|
background_is_transparent =
|
25
31
|
json.dig('channelDepth', 'alpha') &&
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: image_quality_check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Wienert
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|