Sé que soy muy tarde a la fiesta, pero mucho ha cambiado desde que esta pregunta fue publicada en primer lugar, por lo que aquí es cómo se puede hacer hoy en día el uso de al menos la versión 2.15.4
de rmagick
Asumiendo usted tiene la imagen en algún lugar accesible:
image = Magick::Image.new(path_to_file)
image.background_color = 'none'
Si también desea recortar la imagen por lo que es tan grande como límites, basta con utilizar .trim!
image.trim!
EDIT:
Resulta que la solución anterior no funciona muy bien para todos los casos de uso. Una solución más general es la siguiente:
# the image needs to be in 'PNG' format
image.format = 'PNG'
# set a fuzz on the image depending on how accurate you want to be
image.fuzz = '10%'
# get the image background color
background_color = image.background_color
# convert pixels based on their color to being transparent
# the fuzz set above controls how accurate the conversion will be
image.paint_transparent(background_color)
¿Cómo convertir eso a rmagick? – hadees
@hadees esto parece un buen comienzo: [Comprender la conversión de ImageMagick y traducir a Ruby RMagick] (http://stackoverflow.com/questions/4132787/understanding-imagemagicks-convert-and-translating-to-ruby-rmagick) –