paperclip-vips 1.2.1 → 1.2.2

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: 3ee434152fdb78f28ebf9c7c284947f5f1ead3341b419b518f3ba546f4c32578
4
- data.tar.gz: 72a3e1263f7c165ec096cec5111bab762693992507bc769678cd5f1ad7a0e42e
3
+ metadata.gz: 7ae2f6d67f0b4f56d5fe0a24af01b01c424d54a16ddc0b9e7d0b8abef95e3bfe
4
+ data.tar.gz: 8db36f72a48bea6b6e071fb65daf65112a67d5bf46d641f45c9bb2538a25aa82
5
5
  SHA512:
6
- metadata.gz: 5c505d092254d9dc6ad9170cf7fc1a1b6ed45302e9a6eb77feb7d7be2d1f8950688ea1d1aa86698f0dd392a59e29cb3cc52cf0b299ea0a861195934d2a9daa60
7
- data.tar.gz: 3ee2067929f1bf42765f52c3e7986254cce4dbe52d83393f7a1743c5589a9854a08970fc12afafb88a50f05e89ba984719098d4455731fcb6356e272c23d3afd
6
+ metadata.gz: 1a9b022534d9463681394514795cc6966d85798c0c28da2fae5dc4f7f9f2d3d8ab6341c6f99fcd80c745413b7e85edf39105b45819e271b375420d32b4d4c388
7
+ data.tar.gz: 0d282b14f4ca78798509ef4ddfee89803cca46647e99c0c893879b4ae66a8603adb565d3557c64657d773a0374ea1dd3205dab73c54a22b364492bcf26f9f35d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [1.2.2] - 2022-04-13
2
+
3
+ - Add support for `auto_orient` option
4
+
1
5
  ## [1.2.1] - 2022-01-31
2
6
 
3
7
  - Update dev dependencies
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paperclip-vips (1.2.1)
4
+ paperclip-vips (1.2.2)
5
5
  paperclip (>= 5.0.0)
6
6
  ruby-vips (~> 2.1)
7
7
 
@@ -1,7 +1,7 @@
1
1
  module Paperclip
2
2
  class Vips < Processor
3
- attr_accessor :current_geometry, :target_geometry, :format, :whiny, :convert_options,
4
- :source_file_options, :auto_orient
3
+ attr_accessor :auto_orient, :convert_options, :current_geometry, :format, :source_file_options,
4
+ :target_geometry, :whiny
5
5
 
6
6
  def initialize(file, options = {}, attachment = nil)
7
7
  super
@@ -11,7 +11,10 @@ module Paperclip
11
11
  @target_geometry = options.fetch(:string_geometry_parser, Geometry).parse(geometry)
12
12
  @current_geometry = options.fetch(:file_geometry_parser, Geometry).from_file(@file)
13
13
  @whiny = options.fetch(:whiny, true)
14
-
14
+
15
+ @auto_orient = options.fetch(:auto_orient, true)
16
+ @convert_options = options[:convert_options]
17
+
15
18
  @current_format = current_format(file).downcase
16
19
  @format = options[:format] || @current_format
17
20
 
@@ -67,8 +70,8 @@ module Paperclip
67
70
  end
68
71
 
69
72
  def process_convert_options(image)
70
- if image && @options[:convert_options].present?
71
- commands = JSON.parse(@options[:convert_options], symbolize_names: true)
73
+ if image
74
+ commands = parsed_convert_commands(@convert_options)
72
75
  commands.each do |cmd|
73
76
  image = ::Vips::Operation.call(cmd[:cmd], [image, *cmd[:args]], cmd[:optional] || {})
74
77
  end
@@ -77,6 +80,20 @@ module Paperclip
77
80
  return image
78
81
  end
79
82
 
83
+ def parsed_convert_commands(convert_options)
84
+ begin
85
+ commands = JSON.parse(convert_options, symbolize_names: true)
86
+ rescue
87
+ commands = []
88
+ end
89
+
90
+ if @auto_orient && commands.exclude?({ cmd: "autorot" })
91
+ commands.unshift({ cmd: "autorot" })
92
+ end
93
+
94
+ return commands
95
+ end
96
+
80
97
  def save_thumbnail(thumbnail, path)
81
98
  case @current_format
82
99
  when ".jpeg", ".jpg"
@@ -1,3 +1,3 @@
1
1
  module PaperclipVips
2
- VERSION = "1.2.1"
2
+ VERSION = "1.2.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperclip-vips
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken Greeff
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-31 00:00:00.000000000 Z
11
+ date: 2022-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: paperclip