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

StackOverflow https://stackoverflow.com/questions/11388517

  •  19-06-2021
  •  | 
  •  

Pregunta

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?

¿Fue útil?

Solución

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top