has_images 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/README.md +9 -0
  2. data/lib/digineo/image.rb +22 -21
  3. metadata +3 -3
data/README.md CHANGED
@@ -156,5 +156,14 @@ add the following to your config/enviroment.rb
156
156
  => Digineo::ImageType::Exception: Could not find ImageType with name invalid image type
157
157
 
158
158
 
159
+ ### Image cropping
160
+
161
+ has_images also supports image cropping
162
+
163
+ user = User.first
164
+ user.avatar.crop(:style => :original, :x1 => 1, :y1 => 1, :x2 => 100, :y2 => 100, :width => 100, :height => 100)
165
+
166
+ this will use the original-image and crops the area between 1x1 and 100x100 and regenerates all thumbnails afterwards
167
+
159
168
  Copyright (c) 2010 Dennis Meise [Digineo GmbH](http://www.digineo.de/ "Digineo GmbH") , released under the MIT license
160
169
 
data/lib/digineo/image.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'RMagick'
1
+ #require 'RMagick'
2
2
  class Digineo::Image < ActiveRecord::Base
3
3
 
4
4
  set_table_name :digineo_images
@@ -62,26 +62,27 @@ class Digineo::Image < ActiveRecord::Base
62
62
  save
63
63
  end
64
64
 
65
- def crop(params = {:style => :original})
66
-
67
- args = [params[:x1].to_i, params[:y1].to_i, params[:width].to_i, params[:height].to_i]
68
-
69
- if old_original = file.to_file(params[:style])
70
- orig_img = Magick::ImageList.new
71
- orig_img.from_blob(old_original.read)
72
- orig_img.crop!(*args)
73
-
74
- new_img = File.open(file.path(:original), "w")
75
- new_img.write(orig_img.to_blob)
76
- new_img.close
77
-
78
-
79
- file.reprocess!
80
- save
81
- else
82
- true
83
- end
84
- end
65
+
66
+ # def crop(params = {:style => :original})
67
+ #
68
+ # args = [params[:x1].to_i, params[:y1].to_i, params[:width].to_i, params[:height].to_i]
69
+ #
70
+ # if old_original = file.to_file(params[:style])
71
+ # orig_img = Magick::ImageList.new
72
+ # orig_img.from_blob(old_original.read)
73
+ # orig_img.crop!(*args)
74
+ #
75
+ # new_img = File.open(file.path(:original), "w")
76
+ # new_img.write(orig_img.to_blob)
77
+ # new_img.close
78
+ #
79
+ #
80
+ # file.reprocess!
81
+ # save
82
+ # else
83
+ # true
84
+ # end
85
+ # end
85
86
 
86
87
  private
87
88
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_images
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 2
10
- version: 0.2.2
9
+ - 3
10
+ version: 0.2.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dennis Meise