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
d1920aab
Commit
d1920aab
authored
Nov 16, 2012
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Actually do the auto_orientation
parent
f2320979
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
24 additions
and
59 deletions
+24
-59
lib/paperclip/geometry_detector_factory.rb
+2
-2
lib/paperclip/helpers.rb
+1
-1
lib/paperclip/thumbnail.rb
+3
-0
test/geometry_detector_test.rb
+0
-0
test/geometry_parser_test.rb
+0
-0
test/geometry_test.rb
+8
-0
test/thumbnail_test.rb
+10
-56
No files found.
lib/paperclip/geometry_detector_factory.rb
View file @
d1920aab
...
@@ -6,8 +6,8 @@ module Paperclip
...
@@ -6,8 +6,8 @@ module Paperclip
end
end
def
make
def
make
GeometryParser
.
new
(
geometry_string
.
strip
).
make
||
geometry
=
GeometryParser
.
new
(
geometry_string
.
strip
).
make
raise
(
Errors
::
NotIdentifiedByImageMagickError
.
new
)
geometry
||
raise
(
Errors
::
NotIdentifiedByImageMagickError
.
new
)
end
end
private
private
...
...
lib/paperclip/helpers.rb
View file @
d1920aab
...
@@ -17,7 +17,7 @@ module Paperclip
...
@@ -17,7 +17,7 @@ module Paperclip
# :expected_outcodes -> An array of integers that defines the expected exit codes
# :expected_outcodes -> An array of integers that defines the expected exit codes
# of the binary. Defaults to [0].
# of the binary. Defaults to [0].
#
#
# :log_command -> Log the command being run when set to true (defaults to
fals
e).
# :log_command -> Log the command being run when set to true (defaults to
tru
e).
# This will only log if logging in general is set to true as well.
# This will only log if logging in general is set to true as well.
#
#
# :swallow_stderr -> Set to true if you don't care what happens on STDERR.
# :swallow_stderr -> Set to true if you don't care what happens on STDERR.
...
...
lib/paperclip/thumbnail.rb
View file @
d1920aab
...
@@ -39,6 +39,9 @@ module Paperclip
...
@@ -39,6 +39,9 @@ module Paperclip
@format
=
options
[
:format
]
@format
=
options
[
:format
]
@animated
=
options
[
:animated
].
nil?
?
true
:
options
[
:animated
]
@animated
=
options
[
:animated
].
nil?
?
true
:
options
[
:animated
]
@auto_orient
=
options
[
:auto_orient
].
nil?
?
true
:
options
[
:auto_orient
]
@auto_orient
=
options
[
:auto_orient
].
nil?
?
true
:
options
[
:auto_orient
]
if
@auto_orient
&&
@current_geometry
.
respond_to?
(
:auto_orient
)
@current_geometry
.
auto_orient
end
@source_file_options
=
@source_file_options
.
split
(
/\s+/
)
if
@source_file_options
.
respond_to?
(
:split
)
@source_file_options
=
@source_file_options
.
split
(
/\s+/
)
if
@source_file_options
.
respond_to?
(
:split
)
@convert_options
=
@convert_options
.
split
(
/\s+/
)
if
@convert_options
.
respond_to?
(
:split
)
@convert_options
=
@convert_options
.
split
(
/\s+/
)
if
@convert_options
.
respond_to?
(
:split
)
...
...
test/geometry_detector_
factory_
test.rb
→
test/geometry_detector_test.rb
View file @
d1920aab
File moved
test/geometry_parser_
factory_
test.rb
→
test/geometry_parser_test.rb
View file @
d1920aab
File moved
test/geometry_test.rb
View file @
d1920aab
...
@@ -139,6 +139,14 @@ class GeometryTest < Test::Unit::TestCase
...
@@ -139,6 +139,14 @@ class GeometryTest < Test::Unit::TestCase
assert_equal
434
,
@geo
.
width
assert_equal
434
,
@geo
.
width
end
end
should
'calculate an EXIF-rotated image dimensions from a path'
do
file
=
fixture_file
(
"rotated.jpg"
)
assert_nothing_raised
{
@geo
=
Paperclip
::
Geometry
.
from_file
(
file
)
}
@geo
.
auto_orient
assert_equal
300
,
@geo
.
height
assert_equal
200
,
@geo
.
width
end
should
"not generate from a bad file"
do
should
"not generate from a bad file"
do
file
=
"/home/This File Does Not Exist.omg"
file
=
"/home/This File Does Not Exist.omg"
assert_raise
(
Paperclip
::
Errors
::
NotIdentifiedByImageMagickError
){
@geo
=
Paperclip
::
Geometry
.
from_file
(
file
)
}
assert_raise
(
Paperclip
::
Errors
::
NotIdentifiedByImageMagickError
){
@geo
=
Paperclip
::
Geometry
.
from_file
(
file
)
}
...
...
test/thumbnail_test.rb
View file @
d1920aab
...
@@ -128,6 +128,16 @@ class ThumbnailTest < Test::Unit::TestCase
...
@@ -128,6 +128,16 @@ class ThumbnailTest < Test::Unit::TestCase
end
end
end
end
should
'properly crop a EXIF-rotated image'
do
file
=
File
.
new
(
fixture_file
(
'rotated.jpg'
))
thumb
=
Paperclip
::
Thumbnail
.
new
(
file
,
:geometry
=>
"50x50#"
)
output_file
=
thumb
.
make
command
=
Cocaine
::
CommandLine
.
new
(
"identify"
,
"-format %wx%h :file"
)
assert_equal
"50x50"
,
command
.
run
(
:file
=>
output_file
.
path
).
strip
end
context
"being thumbnailed with source file options set"
do
context
"being thumbnailed with source file options set"
do
setup
do
setup
do
@thumb
=
Paperclip
::
Thumbnail
.
new
(
@file
,
@thumb
=
Paperclip
::
Thumbnail
.
new
(
@file
,
...
@@ -306,62 +316,6 @@ class ThumbnailTest < Test::Unit::TestCase
...
@@ -306,62 +316,6 @@ class ThumbnailTest < Test::Unit::TestCase
end
end
end
end
context
"An image with exif orientation"
do
setup
do
@file
=
File
.
new
(
fixture_file
(
"rotated.jpg"
),
'rb'
)
end
teardown
{
@file
.
close
}
context
"With :auto_orient => false"
do
setup
do
@thumb
=
Paperclip
::
Thumbnail
.
new
(
@file
,
:geometry
=>
"100x50"
,
:auto_orient
=>
false
)
end
should
"send the right command to convert when sent #make"
do
@thumb
.
expects
(
:convert
).
with
do
|*
arg
|
arg
[
0
]
==
':source -resize "100x50" :dest'
&&
arg
[
1
][
:source
]
==
"
#{
File
.
expand_path
(
@thumb
.
file
.
path
)
}
[0]"
end
@thumb
.
make
end
should
"create the thumbnail when sent #make"
do
dst
=
@thumb
.
make
assert_match
/75x50/
,
`identify "
#{
dst
.
path
}
"`
end
should
"not touch the orientation information"
do
dst
=
@thumb
.
make
assert_match
/exif:Orientation=6/
,
`identify -format "%[EXIF:*]" "
#{
dst
.
path
}
"`
end
end
context
"Without :auto_orient => false"
do
setup
do
@thumb
=
Paperclip
::
Thumbnail
.
new
(
@file
,
:geometry
=>
"100x50"
)
end
should
"send the right command to convert when sent #make"
do
@thumb
.
expects
(
:convert
).
with
do
|*
arg
|
arg
[
0
]
==
':source -auto-orient -resize "100x50" :dest'
&&
arg
[
1
][
:source
]
==
"
#{
File
.
expand_path
(
@thumb
.
file
.
path
)
}
[0]"
end
@thumb
.
make
end
should
"create the thumbnail when sent #make"
do
dst
=
@thumb
.
make
assert_match
/33x50/
,
`identify "
#{
dst
.
path
}
"`
end
should
"remove the orientation information"
do
dst
=
@thumb
.
make
assert_match
/exif:Orientation=1/
,
`identify -format "%[EXIF:*]" "
#{
dst
.
path
}
"`
end
end
end
context
"A multipage PDF"
do
context
"A multipage PDF"
do
setup
do
setup
do
@file
=
File
.
new
(
fixture_file
(
"twopage.pdf"
),
'rb'
)
@file
=
File
.
new
(
fixture_file
(
"twopage.pdf"
),
'rb'
)
...
...
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