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
a0681085
Commit
a0681085
authored
Sep 26, 2011
by
Aldo Sarmiento
Committed by
Jon Yurek
Sep 30, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not release reference to possible tempfile object
parent
0df5a960
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
+6
-4
lib/paperclip/geometry.rb
+6
-4
No files found.
lib/paperclip/geometry.rb
View file @
a0681085
...
...
@@ -13,18 +13,20 @@ module Paperclip
# Uses ImageMagick to determing the dimensions of a file, passed in as either a
# File or path.
# NOTE: (race cond) Do not reassign the 'file' variable inside this method as it is likely to be
# a Tempfile object, which would be eligible for file deletion when no longer referenced.
def
self
.
from_file
file
file
=
file
.
path
if
file
.
respond_to?
"path"
raise
(
Paperclip
::
NotIdentifiedByImageMagickError
.
new
(
"Cannot find the geometry of a file with a blank name"
))
if
file
.
blank?
file
_path
=
file
.
respond_to?
(
:path
)
?
file
.
path
:
file
raise
(
Paperclip
::
NotIdentifiedByImageMagickError
.
new
(
"Cannot find the geometry of a file with a blank name"
))
if
file
_path
.
blank?
geometry
=
begin
Paperclip
.
run
(
"identify"
,
"-format %wx%h :file"
,
:file
=>
"
#{
file
}
[0]"
)
Paperclip
.
run
(
"identify"
,
"-format %wx%h :file"
,
:file
=>
"
#{
file
_path
}
[0]"
)
rescue
Cocaine
::
ExitStatusError
""
rescue
Cocaine
::
CommandNotFoundError
=>
e
raise
Paperclip
::
CommandNotFoundError
.
new
(
"Could not run the `identify` command. Please install ImageMagick."
)
end
parse
(
geometry
)
||
raise
(
NotIdentifiedByImageMagickError
.
new
(
"
#{
file
}
is not recognized by the 'identify' command."
))
raise
(
NotIdentifiedByImageMagickError
.
new
(
"
#{
file
_path
}
is not recognized by the 'identify' command."
))
end
# Parses a "WxH" formatted string, where W is the width and H is the height.
...
...
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