Je le code suivant:Imagemagick rails de composition d'image en ajoutant le fond blanc indésirable
begin
big_image = Magick::ImageList.new
#this is an image containing first row of images
first_row = Magick::ImageList.new
#adding images to the first row (Image.read returns an Array, this is why .first is needed)
first_row.push(Magick::Image.read(Rails.root.join("app","assets","images","logo.png")).first)
if @model.avatar.exists?
image = Magick::Image.read(@model.avatar.path).first
image = image.resize_to_fit("450", "401")
first_row.push(image)
end
#adding first row to big image and specify that we want images in first row to be appended in a single image on the same row - argument false on append does that
big_image.push (first_row.append(false))
fileName = @model.id.to_s + ".png"
big_image.append(true).write(Rails.root.join("app","assets","images","shared_logo",fileName))
rescue => e
puts "Errors! -- #{e.inspect}"
end
Les codes met deux images sur la même rangée. Les images sont png. Le problème est que la deuxième image a une hauteur inférieure à la première. La magie d'images remplit la partie restante avec un fond blanc non désiré. Je veux garder la transparence sur l'image combinée.
ne fonctionne pas ... – Kerby82
@ Kerby82 ok alors –