Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added fleximage:dimensions rake task for populating width and height …

…magic columns. [#3 state:resolved]
  • Loading branch information...
commit 38e089712fbf1afaf7809b43923b76572ad9882e 1 parent 192ddcb
@Squeegy Squeegy authored
Showing with 19 additions and 7 deletions.
  1. +19 −7 tasks/fleximage_tasks.rake
View
26 tasks/fleximage_tasks.rake
@@ -1,12 +1,24 @@
namespace :fleximage do
- namespace :convert do
-
- # Find the model class
- def model_class
- raise 'You must specify a FLEXIMAGE_CLASS=MyClass' unless ENV['FLEXIMAGE_CLASS']
- @model_class ||= ENV['FLEXIMAGE_CLASS'].camelcase.constantize
+
+ # Find the model class
+ def model_class
+ raise 'You must specify a FLEXIMAGE_CLASS=MyClass' unless ENV['FLEXIMAGE_CLASS']
+ @model_class ||= ENV['FLEXIMAGE_CLASS'].camelcase.constantize
+ end
+
+ desc "Populate width and height magic columns from the current image store. Useful when migrating from on old installation."
+ task :dimensions => :environment do
+ model_class.find(:all).each do |obj|
+ if obj.has_image?
+ img = obj.load_image
+ obj.update_attribute :image_width, img.columns if obj.respond_to?(:image_width=)
+ obj.update_attribute :image_height, img.rows if obj.respond_to?(:image_height=)
+ end
end
-
+ end
+
+ namespace :convert do
+
def convert_directory_format(to_format)
model_class.find(:all).each do |obj|
Please sign in to comment.
Something went wrong with that request. Please try again.