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
3b8ed8df
Commit
3b8ed8df
authored
Aug 21, 2008
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added the 'paperclip_extended' stuff for supplying extra commands to ImageMagick
parent
715ff88a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
5 deletions
+9
-5
lib/paperclip/attachment.rb
+3
-1
lib/paperclip/thumbnail.rb
+6
-4
No files found.
lib/paperclip/attachment.rb
View file @
3b8ed8df
...
...
@@ -15,7 +15,7 @@ module Paperclip
}
end
attr_reader
:name
,
:instance
,
:styles
,
:default_style
attr_reader
:name
,
:instance
,
:styles
,
:default_style
,
:convert_options
# Creates an Attachment object. +name+ is the name of the attachment, +instance+ is the
# ActiveRecord object instance it's attached to, and +options+ is the same as the hash
...
...
@@ -34,6 +34,7 @@ module Paperclip
@default_style
=
options
[
:default_style
]
@storage
=
options
[
:storage
]
@whiny_thumbnails
=
options
[
:whiny_thumbnails
]
@convert_options
=
options
[
:convert_options
]
@options
=
options
@queued_for_delete
=
[]
@queued_for_write
=
{}
...
...
@@ -247,6 +248,7 @@ module Paperclip
@queued_for_write
[
name
]
=
Thumbnail
.
make
(
@queued_for_write
[
:original
],
dimensions
,
format
,
convert_options
[
name
],
@whiny_thumnails
)
rescue
PaperclipError
=>
e
@errors
<<
e
.
message
if
@whiny_thumbnails
...
...
lib/paperclip/thumbnail.rb
View file @
3b8ed8df
...
...
@@ -2,18 +2,19 @@ module Paperclip
# Handles thumbnailing images that are uploaded.
class
Thumbnail
attr_accessor
:file
,
:current_geometry
,
:target_geometry
,
:format
,
:whiny_thumbnails
attr_accessor
:file
,
:current_geometry
,
:target_geometry
,
:format
,
:whiny_thumbnails
,
:convert_options
# Creates a Thumbnail object set to work on the +file+ given. It
# will attempt to transform the image into one defined by +target_geometry+
# which is a "WxH"-style string. +format+ will be inferred from the +file+
# unless specified. Thumbnail creation will raise no errors unless
# +whiny_thumbnails+ is true (which it is, by default.
def
initialize
file
,
target_geometry
,
format
=
nil
,
whiny_thumbnails
=
true
def
initialize
file
,
target_geometry
,
format
=
nil
,
convert_options
=
nil
,
whiny_thumbnails
=
true
@file
=
file
@crop
=
target_geometry
[
-
1
,
1
]
==
'#'
@target_geometry
=
Geometry
.
parse
target_geometry
@current_geometry
=
Geometry
.
from_file
file
@convert_options
=
convert_options
@whiny_thumbnails
=
whiny_thumbnails
@current_format
=
File
.
extname
(
@file
.
path
)
...
...
@@ -24,8 +25,8 @@ module Paperclip
# Creates a thumbnail, as specified in +initialize+, +make+s it, and returns the
# resulting Tempfile.
def
self
.
make
file
,
dimensions
,
format
=
nil
,
whiny_thumbnails
=
true
new
(
file
,
dimensions
,
format
,
whiny_thumbnails
).
make
def
self
.
make
file
,
dimensions
,
format
=
nil
,
convert_options
=
nil
,
whiny_thumbnails
=
true
new
(
file
,
dimensions
,
format
,
convert_options
,
whiny_thumbnails
).
make
end
# Returns true if the +target_geometry+ is meant to crop.
...
...
@@ -61,6 +62,7 @@ module Paperclip
scale
,
crop
=
@current_geometry
.
transformation_to
(
@target_geometry
,
crop?
)
trans
=
"-scale
\"
#{
scale
}
\"
"
trans
<<
" -crop
\"
#{
crop
}
\"
+repage"
if
crop
trans
<<
"
#{
convert_options
}
"
if
convert_options
trans
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