we now store image height and width locally; still need to federate the values

This commit is contained in:
Maxwell Salzberg 2012-04-20 12:22:12 -07:00
parent b4d50510f9
commit 1b2440f68a
4 changed files with 26 additions and 2 deletions

View file

@ -20,5 +20,11 @@ class UnprocessedImage < CarrierWave::Uploader::Base
version :thumb_small
version :thumb_medium
version :thumb_large
version :scaled_full
version :scaled_full do
process :get_version_dimensions
end
def get_version_dimensions
model.width, model.height = `identify -format "%wx%h" #{file.path}`.split(/x/)
end
end

View file

@ -0,0 +1,6 @@
class AddWidthAndHeightToPhotos < ActiveRecord::Migration
def change
add_column :photos, :height, :integer
add_column :photos, :width, :integer
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20120414005431) do
ActiveRecord::Schema.define(:version => 20120420185823) do
create_table "account_deletions", :force => true do |t|
t.string "diaspora_handle"
@ -297,6 +297,8 @@ ActiveRecord::Schema.define(:version => 20120414005431) do
t.string "unprocessed_image"
t.string "status_message_guid"
t.integer "comments_count"
t.integer "height"
t.integer "width"
end
add_index "photos", ["status_message_guid"], :name => "index_photos_on_status_message_guid"

View file

@ -125,7 +125,11 @@ describe Photo do
context 'with a saved photo' do
before do
UnprocessedImage.enable_processing = true
@photo.unprocessed_image.store! File.open(@fixture_name)
UnprocessedImage.enable_processing = false
end
it 'should have text' do
@photo.text= "cool story, bro"
@ -145,6 +149,12 @@ describe Photo do
@photo.url.include?(@fixture_filename).should be false
@photo.url(:thumb_medium).include?("/" + @fixture_filename).should be false
end
it 'should save the image dimensions' do
@photo.width.should == 40
@photo.height.should == 40
end
end
describe 'non-image files' do