मैं जानता हूँ कि मैं बहुत पार्टी के लिए देर से कर रहा हूँ, लेकिन जब से यह सवाल पहले पोस्ट किया गया था बहुत कुछ बदल गया है, तो आप निम्न तरीके से यह आज कम से कम rmagick
की 2.15.4
संस्करण मान लिया जाये कि का उपयोग कर सकते है आप छवि कहीं सुलभ है:
image = Magick::Image.new(path_to_file)
image.background_color = 'none'
आप भी छवि ट्रिम करने के लिए चाहते हैं तो यह केवल यह सीमाओं के रूप में के रूप में बड़ा है, बस का उपयोग .trim!
image.trim!
संपादित करें:
बाहर कर देता है इसके बाद के संस्करण समाधान वास्तव में सभी उपयोग के मामलों के लिए काम नहीं करता। एक और सामान्य समाधान यह है:
# 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)
स्रोत
2016-12-22 11:30:47
आप इसे rmagick में कैसे परिवर्तित करते हैं? – hadees
@ hadees यह एक अच्छी शुरुआत की तरह दिखता है: [ImageMagick को समझना और रूबी RMagick में अनुवाद करना] (http://stackoverflow.com/questions/4132787/understanding-imagemagicks-convert-and-translating-to-ruby-rmagick) –