esimov / triangle

Convert images to computer generated art using delaunay triangulation.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Panic for image with specific dimension

equal-l2 opened this issue · comments

Version: 1.0.3
When a 1px height (e.g. 1x1, 10x1, 100x1) image is given as an input, triangle fails to run.
(FYI a 1px width (e.g. 1x10, 1x100) image is successfully processed)

% triangle -in test.jpg -out out.jpg
Generating triangulated image... -panic: runtime error: index out of range

goroutine 1 [running]:
github.com/esimov/triangle.StackBlur(0xc0000aa6c0, 0xc000000004, 0xc0000aa6c0)
	/private/tmp/triangle-20190310-60366-glg0jh/triangle-1.0.3/src/github.com/esimov/triangle/stackblur.go:259 +0xf29
github.com/esimov/triangle.(*Image).Draw(0xc0000ddbe8, 0x140d280, 0xc0000b4070, 0x140d280, 0xc000010010, 0x1431be0, 0x0, 0x1, 0x1c08400, 0x20300000000000, ...)
	/private/tmp/triangle-20190310-60366-glg0jh/triangle-1.0.3/src/github.com/esimov/triangle/process.go:102 +0x3ad
main.main()
	/private/tmp/triangle-20190310-60366-glg0jh/triangle-1.0.3/src/github.com/esimov/triangle/cmd/triangle/main.go:178 +0xd98

Failing to process such an image is fine, but is it possible to give a more informative message (like "the input is too small")?

@equal-l2 thank you for reporting this issue. This is fixed now. Please revise it and tell me if is still reproducing.

It successfully emits message now, though there's some typo in the message.

err := errors.New("The image widht and height must be greather than 1px.\n")

I think widht should be width and greather should be greater.

Thanks for notifying this, i have corrected them.

Anyway, the problem has solved. Thank you for fixing.