Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
paperclip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
paperclip
Commits
0632282c
Commit
0632282c
authored
Apr 10, 2014
by
Patrick Byrne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optionally disable inspecting EXIF for orientation
parent
41da3a3c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
2 deletions
+22
-2
lib/paperclip.rb
+4
-1
lib/paperclip/geometry_detector_factory.rb
+3
-1
spec/paperclip/geometry_detector_spec.rb
+15
-0
No files found.
lib/paperclip.rb
View file @
0632282c
...
...
@@ -75,6 +75,8 @@ module Paperclip
# * 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
# 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
@options
||=
{
:whiny
=>
true
,
...
...
@@ -83,7 +85,8 @@ module Paperclip
:log
=>
true
,
:log_command
=>
true
,
:swallow_stderr
=>
true
,
:content_type_mappings
=>
{}
:content_type_mappings
=>
{},
:use_exif_orientation
=>
true
}
end
...
...
lib/paperclip/geometry_detector_factory.rb
View file @
0632282c
...
...
@@ -14,9 +14,11 @@ module Paperclip
def
geometry_string
begin
orientation
=
Paperclip
.
options
[
:use_exif_orientation
]
?
"%[exif:orientation]"
:
"1"
Paperclip
.
run
(
"identify"
,
"-format '%wx%h,
%[exif:orientation]
' :file"
,
{
"-format '%wx%h,
#{
orientation
}
' :file"
,
{
:file
=>
"
#{
path
}
[0]"
},
{
:swallow_stderr
=>
true
...
...
spec/paperclip/geometry_detector_spec.rb
View file @
0632282c
...
...
@@ -20,5 +20,20 @@ describe Paperclip::GeometryDetector do
expect
(
output
).
to
eq
:correct
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment