pothoven-attachment_fu 3.2.1 → 3.2.2
Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG
CHANGED
@@ -1,5 +1,9 @@
|
|
1
|
+
* Nov 15, 2012 *
|
2
|
+
* Removed 'crop:' option as already included when prefixing geometry with a 'c'. Add note to docs.
|
3
|
+
* Added option to sharpen resized images ':sharpen_on_resize'
|
4
|
+
|
1
5
|
* Oct 26, 2012 *
|
2
|
-
* Merged with https://github.com/tdd/attachment_fu fork to include GEM support for use in Rails 3.2
|
6
|
+
* Merged with https://github.com/tdd/attachment_fu fork to include GEM support for use in Rails 3.2, and bumped version to 3.2.x to indicate Rails 3.2 support.
|
3
7
|
|
4
8
|
* Oct 25, 2012 *
|
5
9
|
* Fix to support Ruby 1.9.3
|
@@ -37,29 +37,8 @@ module Technoweenie # :nodoc:
|
|
37
37
|
end if image?
|
38
38
|
end
|
39
39
|
|
40
|
-
# Override image resizing method so we can support the crop option
|
41
|
-
# Thanks: http://stuff-things.net/2008/02/21/quick-and-dirty-cropping-images-with-attachment_fu/
|
42
|
-
def resize_image(img, size)
|
43
|
-
img.delete_profile('*')
|
44
|
-
|
45
|
-
# resize_image take size in a number of formats, we just want
|
46
|
-
# Strings in the form of "crop: WxH"
|
47
|
-
if (size.is_a?(String) && size =~ /^crop: (\d*)x(\d*)/i) ||
|
48
|
-
(size.is_a?(Array) && size.first.is_a?(String) &&
|
49
|
-
size.first =~ /^crop: (\d*)x(\d*)/i)
|
50
|
-
img.crop_resized!($1.to_i, $2.to_i)
|
51
|
-
# We need to save the resized image in the same way the
|
52
|
-
# orignal does.
|
53
|
-
quality = img.format.to_s[/JPEG/] && get_jpeg_quality
|
54
|
-
out_file = write_to_temp_file(img.to_blob { self.quality = quality if quality })
|
55
|
-
self.temp_paths.unshift out_file
|
56
|
-
else
|
57
|
-
old_resize_image(img, size) # Otherwise let attachment_fu handle it
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
40
|
# Performs the actual resizing operation for a thumbnail
|
62
|
-
def
|
41
|
+
def resize_image(img, size)
|
63
42
|
size = size.first if size.is_a?(Array) && size.length == 1 && !size.first.is_a?(Fixnum)
|
64
43
|
if size.is_a?(Fixnum) || (size.is_a?(Array) && size.first.is_a?(Fixnum))
|
65
44
|
size = [size, size] if size.is_a?(Fixnum)
|
@@ -68,10 +47,13 @@ module Technoweenie # :nodoc:
|
|
68
47
|
dimensions = size[1..size.size].split("x")
|
69
48
|
img.crop_resized!(dimensions[0].to_i, dimensions[1].to_i)
|
70
49
|
else
|
71
|
-
img.change_geometry(size.to_s) { |cols, rows, image|
|
50
|
+
img.change_geometry(size.to_s) { |cols, rows, image|
|
51
|
+
image.resize!(cols<1 ? 1 : cols, rows<1 ? 1 : rows)
|
52
|
+
}
|
72
53
|
end
|
73
54
|
self.width = img.columns if respond_to?(:width)
|
74
55
|
self.height = img.rows if respond_to?(:height)
|
56
|
+
img = img.sharpen if attachment_options[:sharpen_on_resize] && img.changed?
|
75
57
|
img.strip! unless attachment_options[:keep_profile]
|
76
58
|
quality = img.format.to_s[/JPEG/] && get_jpeg_quality
|
77
59
|
out_file = write_to_temp_file(img.to_blob { self.quality = quality if quality })
|
@@ -45,7 +45,8 @@ module Technoweenie # :nodoc:
|
|
45
45
|
# * <tt>:min_size</tt> - Minimum size allowed. 1 byte is the default.
|
46
46
|
# * <tt>:max_size</tt> - Maximum size allowed. 1.megabyte is the default.
|
47
47
|
# * <tt>:size</tt> - Range of sizes allowed. (1..1.megabyte) is the default. This overrides the :min_size and :max_size options.
|
48
|
-
# * <tt>:resize_to</tt> - Used by RMagick to resize images. Pass either an array of width/height, or a geometry string.
|
48
|
+
# * <tt>:resize_to</tt> - Used by RMagick to resize images. Pass either an array of width/height, or a geometry string. Prefix geometry string with 'c' to crop image, ex. 'c100x100'
|
49
|
+
# * <tt>:sharpen_on_resize</tt> - When using RMagick, setting to true will sharpen images after resizing.
|
49
50
|
# * <tt>:jpeg_quality</tt> - Used to provide explicit JPEG quality for thumbnail/resize saves. Can have multiple formats:
|
50
51
|
# * Integer from 0 (basically crap) to 100 (basically lossless, fat files).
|
51
52
|
# * When relying on ImageScience, you can also use one of its +JPEG_xxx+ constants for predefined ratios/settings.
|