David
David

Reputation: 18281

Possible to configure Dragonfly-Gem w/Rails3 to force convert all uploads to image/jpeg?

I've been reading through the DragonFly docs and I think the before_serve clause of DragonFly's configuration is probably where I need to focus, perhaps by setting up some sort of

convert to jpeg if not jpeg

logic there. Or is there a much quicker/simpler way?

Upvotes: 1

Views: 413

Answers (1)

Mark Evans
Mark Evans

Reputation: 311

sorry just saw this. if you want to convert the ORIGINAL to a jpeg then use a model after_assign callback - see http://markevans.github.com/dragonfly/file.Models.html#Callbacks you'd do

image_accessor :avatar do
  after_assign{|a| a.jpg! unless a.format == :jpg }
end

though actually you don't even need the "unless" bit because doing .jpg! on a jpeg won't do anything

Upvotes: 2

Related Questions