Commit 0d3027e7 by Prem Sichanugrist

Merge pull request #1514 from pbyrne/configure-disable-exif-orientation

Optionally disable inspecting EXIF for orientation
parents be04cf02 0632282c
...@@ -75,6 +75,8 @@ module Paperclip ...@@ -75,6 +75,8 @@ module Paperclip
# * command_path: Defines the path at which to find the command line # * command_path: Defines the path at which to find the command line
# programs if they are not visible to Rails the system's search path. Defaults to # programs if they are not visible to Rails the system's search path. Defaults to
# nil, which uses the first executable found in the user's search path. # nil, which uses the first executable found in the user's search path.
# * use_exif_orientation: Whether to inspect EXIF data to determine an
# image's orientation. Defaults to true.
def self.options def self.options
@options ||= { @options ||= {
:whiny => true, :whiny => true,
...@@ -83,7 +85,8 @@ module Paperclip ...@@ -83,7 +85,8 @@ module Paperclip
:log => true, :log => true,
:log_command => true, :log_command => true,
:swallow_stderr => true, :swallow_stderr => true,
:content_type_mappings => {} :content_type_mappings => {},
:use_exif_orientation => true
} }
end end
......
...@@ -14,9 +14,11 @@ module Paperclip ...@@ -14,9 +14,11 @@ module Paperclip
def geometry_string def geometry_string
begin begin
orientation = Paperclip.options[:use_exif_orientation] ?
"%[exif:orientation]" : "1"
Paperclip.run( Paperclip.run(
"identify", "identify",
"-format '%wx%h,%[exif:orientation]' :file", { "-format '%wx%h,#{orientation}' :file", {
:file => "#{path}[0]" :file => "#{path}[0]"
}, { }, {
:swallow_stderr => true :swallow_stderr => true
......
...@@ -20,5 +20,20 @@ describe Paperclip::GeometryDetector do ...@@ -20,5 +20,20 @@ describe Paperclip::GeometryDetector do
expect(output).to eq :correct expect(output).to eq :correct
end end
it 'avoids reading EXIF orientation if so configured' do
begin
Paperclip.options[:use_exif_orientation] = false
Paperclip::GeometryParser.stubs(:new).with("300x200,1").returns(stub(make: :correct))
file = fixture_file("rotated.jpg")
factory = Paperclip::GeometryDetector.new(file)
output = factory.make
expect(output).to eq :correct
ensure
Paperclip.options[:use_exif_orientation] = true
end
end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment