attachment_on_the_fly 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -0
- data/README.rdoc +56 -0
- data/VERSION +1 -1
- data/attachment_on_the_fly.gemspec +3 -7
- data/lib/attachment_on_the_fly.rb +2 -2
- metadata +2 -6
- data/pkg/attachment_on_the_fly-0.0.0.gem +0 -0
- data/pkg/attachment_on_the_fly-0.0.1.gem +0 -0
- data/pkg/attachment_on_the_fly-0.0.2.gem +0 -0
- data/pkg/attachment_on_the_fly-0.0.3.gem +0 -0
data/README
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
See README.rdoc for more information.
|
data/README.rdoc
CHANGED
@@ -1,8 +1,64 @@
|
|
1
1
|
=Attachment on the Fly
|
2
2
|
|
3
|
+
Attachment on the Fly is a module that extends Paperclip by allowing dynamic
|
4
|
+
image resizing without going through ActiveRecord first. This gem can only
|
5
|
+
resize images. If you try to resize a PDF or other attachment, nothing will
|
6
|
+
happen.
|
7
|
+
|
8
|
+
==Requirements
|
9
|
+
|
10
|
+
* thoughtbot-paperclip gem
|
11
|
+
* ImageMagick
|
12
|
+
|
3
13
|
==Quick Start
|
4
14
|
|
15
|
+
Attachment on the Fly is hosted on Gemcutter, so it is recommended that you
|
16
|
+
install the Gemcutter gem before installing Attachment on the Fly.
|
17
|
+
|
18
|
+
See http://gemcutter.org/ for installation instructions. Then:
|
19
|
+
|
20
|
+
sudo gem install attachment_on_the_fly
|
21
|
+
|
22
|
+
Setup your models the same way you normally do with Paperclip. See
|
23
|
+
http://github.com/thoughtbot/paperclip for detailed instructions.
|
24
|
+
|
25
|
+
Once your attachments are working with Paperclip, add this line to the top of
|
26
|
+
your models:
|
27
|
+
|
28
|
+
require "attachment_on_the_fly"
|
29
|
+
|
30
|
+
To use, reference the instance of your attachment like this:
|
31
|
+
|
32
|
+
<%= my_image_model.attachment.s_640_480 %>
|
33
|
+
|
34
|
+
This will output an image path based on your url interpolation and a resized
|
35
|
+
image named S_640_480_your_image_name.jpg (or gif or png).
|
36
|
+
|
5
37
|
==Usage
|
6
38
|
|
39
|
+
Attachment on the Fly can accept three types of inputs: width by height, height
|
40
|
+
proportional, and width proportional.
|
41
|
+
|
42
|
+
my_image_model.attachment.s_640_480 will generate a 640x480 pixel image.
|
43
|
+
|
44
|
+
my_image_model.attachment.s_640_width will generate an image that is 640 pixels
|
45
|
+
wide and proportionally high based on the original image dimensions.
|
46
|
+
|
47
|
+
my_image_model.attachment.s_480_height will generate an image that is 480 pixels
|
48
|
+
high and proportionally wide based on the original image dimensions.
|
49
|
+
|
50
|
+
When an image's instance is first accessed through the s_ method, a new image
|
51
|
+
will be generated according to the image's path interpolation. Then, every time
|
52
|
+
the image is accessed with the same dimensions, the previously generated image
|
53
|
+
will be used. This allows the flexibility to resize images at will but still be
|
54
|
+
able to cache previously generated images.
|
55
|
+
|
56
|
+
Currently, convert's sharpen is set to 1. If you need to change the sharpness
|
57
|
+
or any other of convert's command line options, you will need to do so in the
|
58
|
+
final lines of lib/attachment_on_the_fly.rb. We are working on a feature to do
|
59
|
+
this dynamically, but it is not available yet.
|
60
|
+
|
7
61
|
==Contributing
|
8
62
|
|
63
|
+
If you find this gem useful, please post your comments, bugs, patches and
|
64
|
+
suggestions on our Github site at http://github.com/drpentode/Attachment-on-the-Fly.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{attachment_on_the_fly}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jeff Sutherland"]
|
12
|
-
s.date = %q{2009-11-
|
12
|
+
s.date = %q{2009-11-25}
|
13
13
|
s.description = %q{A Paperclip mix-in to allow auto-generation of resized images}
|
14
14
|
s.email = %q{jefferey.sutherland@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -23,11 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
"VERSION",
|
24
24
|
"attachment_on_the_fly.gemspec",
|
25
25
|
"init.rb",
|
26
|
-
"lib/attachment_on_the_fly.rb"
|
27
|
-
"pkg/attachment_on_the_fly-0.0.0.gem",
|
28
|
-
"pkg/attachment_on_the_fly-0.0.1.gem",
|
29
|
-
"pkg/attachment_on_the_fly-0.0.2.gem",
|
30
|
-
"pkg/attachment_on_the_fly-0.0.3.gem"
|
26
|
+
"lib/attachment_on_the_fly.rb"
|
31
27
|
]
|
32
28
|
s.homepage = %q{http://github.com/drpentode/Attachment-on-the-Fly}
|
33
29
|
s.rdoc_options = ["--charset=UTF-8"]
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Methods to allow attachment modification on-the-fly
|
2
|
+
# Methods to allow attachment modification on-the-fly
|
3
3
|
# the paperclip attachment attribute should be called "attachment" on the model
|
4
4
|
#
|
5
5
|
Paperclip::Attachment.class_eval do
|
@@ -86,7 +86,7 @@ Paperclip::Attachment.class_eval do
|
|
86
86
|
`convert -colorspace RGB -geometry #{width} -quality 100 -sharpen 1 #{original} #{newfilename} 2>&1 > /dev/null`
|
87
87
|
elsif kind == "both"
|
88
88
|
# resize_image infilename, outfilename, height, width
|
89
|
-
`convert -colorspace RGB -geometry #{
|
89
|
+
`convert -colorspace RGB -geometry #{width}x#{height} -quality 100 -sharpen 1 #{original} #{newfilename} 2>&1 > /dev/null`
|
90
90
|
end
|
91
91
|
|
92
92
|
return new_path
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attachment_on_the_fly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Sutherland
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-25 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -30,10 +30,6 @@ files:
|
|
30
30
|
- attachment_on_the_fly.gemspec
|
31
31
|
- init.rb
|
32
32
|
- lib/attachment_on_the_fly.rb
|
33
|
-
- pkg/attachment_on_the_fly-0.0.0.gem
|
34
|
-
- pkg/attachment_on_the_fly-0.0.1.gem
|
35
|
-
- pkg/attachment_on_the_fly-0.0.2.gem
|
36
|
-
- pkg/attachment_on_the_fly-0.0.3.gem
|
37
33
|
has_rdoc: true
|
38
34
|
homepage: http://github.com/drpentode/Attachment-on-the-Fly
|
39
35
|
licenses: []
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|