Cómo cambiar de RMagick a MiniMagick

RMagick has been nothing but a pain in the butt for months (errors out of the clear blue sky on production).

What are the alternatives for the following RMagic code in MiniMagick?...

Magick::CenterGravity
Magick::OverCompositeOp
Magick::Image.new(100,40) { self.background_color = bgcolor }
Magick::Pixel.new colors.collect(&:red).inject(:+)/colors.size

Gracias de antemano.

preguntado el 01 de febrero de 12 a las 03:02

2 Respuestas

You need to translate from Rmagick back to the command line version of ImageMagick(convert or mogrify). This is how I test out ImageMagick operations on my Mac. It's easy to get to MiniMagick from there since it just wraps the mogrify command. Here is a sample of doing a composite operation from the MiniMagick github page for starters:

image = Image.open("original.png")
result = image.composite(Image.open("watermark.png", "jpg") do |c|
  c.gravity "center"
end
result.write "my_output_file.jpg"

I have no experience with Rmagick so I can't help you with that.

Respondido 01 Feb 12, 18:02

Aquí están algunas:

image = Image.open("original_file.png")
result = image.composite(Image.open("other_image.jpg") do |c|
  c.compose "Over"    # OverCompositeOp
  c.background "blue"
  c.gravity "center"
end
result.write "new_file.jpg"

Respondido el 09 de junio de 15 a las 20:06

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.