vendredi 27 janvier 2017

Ruby rmagick: How to make text more bold?

def change_image_labels(feed_data)
 for data in feed_data
  img = Image::read(@tmpdir_file_path+"/#{data[0]}.png").first.resize(600,600)
 redback = Image::read("#{Rails.root}/tmp/redback.png")[0]
 txt = Magick::Draw.new
 redback.annotate(txt,0,0,0,0,data[2]){
   txt.gravity = Magick::WestGravity
   txt.pointsize = 50
   txt.fill = "#ffffff"
   txt.font_family = 'helvetica'
   txt.font_weight = Magick::BoldWeight
 }
 img = img.composite(redback, 0, 30, AtopCompositeOp)
 img.write(@tmpdir_file_path+"/#{data[0]}.png")
end
end

Here I am trying to annotate an image with reb background with a text.

Here `redback.annotate(txt,0,0,0,0,data[2]` `data[2]` refers to the text which contains data like 92% OFF. I want to make it bold.

Please refer to below images-

Actual Result-

enter image description here

Desired Result (Boldness)-

enter image description here

As you can the second image contains a text which is more bold.

Please help.

Aucun commentaire:

Enregistrer un commentaire