Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Paperclip save images as jpg with white background

I'd like to know how to convert png and gif files with alpha channel to jpg with white background with paperclip

I tried this but, it doesn't work

has_attached_file( 
  :photo, 
  :whiny => false, 
  :styles => { 
    :medium => ["300x300>", :jpg], 
    :thumb => ["100x100>", :jpg] 
  }, 
  :convert_options => { :all => '-alpha white -background white'}
)

It saves the file with the gray background.

like image 334
Mathieu Avatar asked Feb 01 '10 19:02

Mathieu


2 Answers

here the solution

has_attached_file :photo,
  :styles => {
    :medium => ["300x300>",:jpg],
    :thumb => ["100x100>", :jpg]
  },
  :convert_options => {
    :all => '-background white -flatten +matte'
  }
like image 177
Mathieu Avatar answered Sep 28 '22 13:09

Mathieu


-alpha remove -background white is preferable. white is not a valid argument for -alpha.

like image 33
Pat McGee Avatar answered Sep 28 '22 13:09

Pat McGee