Image.Text.text raises
tielur opened this issue · comments
Image.Text.text raises when passing black as the text_fill_color
Image.Text.text!("I love this library", text_fill_color: :black)
** (MatchError) no match of right hand side value: {:error, "Could not normalize box with {{357, 48}, 357, 48, 0, 0}"}
(image 0.31.1) lib/image/text.ex:383: Image.Text.simple_text/2
(image 0.31.1) lib/image/text.ex:138: Image.Text.text/2
(image 0.31.1) lib/image/text.ex:268: Image.Text.text!/2
iex:28: (file)
Thanks for the report. That was an interesting one - basically when the text fill color is black (or thereabouts), the trim area is 0 pixels wide and 0 pixels high and therefore the post-creation crop was failing.
I've pushed a commit and wonder if you'd mind trying it out before I publish? I haven't run any test images yet. I'm a little concerned that the results may not be what you expect so your feedback will help work out what else might be required.
I appreciate you taking this lib for a spin and reporting issues, it really helps.
Thanks for the quick fix!
I just checked out main and tried it out, seems to be working with Text
as I expected
def kip do
small_kip = Image.open!("test/images/Kip_small.jpg")
texts = [
{Image.Text.text!("hello", text_fill_color: :black, padding: 10),
x: :center, y: :middle},
{Image.Text.text!("world", text_fill_color: :black, padding: 10), dy: 12}
]
Image.compose(small_kip, texts) |> Image.preview()
end
❤️ the library
Thanks Tyler, definitely helps with motivation. I've started work on the color
lib. Just got to balance time with code, wife and beach for the next week :-)