Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- background_image = Image.read("canvas:khaki") do
- self.size = "700x700"
- end
- background_image = background_image.first
- font_size = 100
- font_path = "../font.ttf"
- width_of_bounding_box = 600
- text_to_print = "Hey this is some text!"
- # Create a new instance of the text wrap helper and give it all the
- # info the class needs..
- helper = RMagickTextWrapHelper.new(text_to_print, font_size, width_of_bounding_box, font_path)
- text = Draw.new
- text.pointsize = font_size
- text.gravity = NorthWestGravity
- text.fill = "#B22222"
- text.font = font_path
- # Call the "get_text_with_line_breaks" to get text
- # with line breaks where needed
- text_wit_line_breaks = helper.get_text_with_line_breaks
- text.annotate(background_image, 700, 700, 0, 0, text_wit_line_breaks)
- background_image.write("rmagick-add-text-to-an-image-with-line-breaks.png")
Advertisement
Add Comment
Please, Sign In to add comment