From d9a2a04ee531e3e126951bf892e6a9207c0b6b64 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Sun, 10 Sep 2023 15:29:54 +0200 Subject: [PATCH] find_trim: fix a crash when enabling `line_art` mode (#3630) --- libvips/arithmetic/find_trim.c | 2 +- test/test-suite/test_arithmetic.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libvips/arithmetic/find_trim.c b/libvips/arithmetic/find_trim.c index 59374ed1a0..6ef22b676c 100644 --- a/libvips/arithmetic/find_trim.c +++ b/libvips/arithmetic/find_trim.c @@ -127,8 +127,8 @@ vips_find_trim_build(VipsObject *object) if (!find_trim->line_art) { if (vips_median(in, &t[1], 3, NULL)) return -1; + in = t[1]; } - in = t[1]; /* Smooth, find difference from bg, abs, threshold. */ diff --git a/test/test-suite/test_arithmetic.py b/test/test-suite/test_arithmetic.py index 09211852e7..5681934979 100644 --- a/test/test-suite/test_arithmetic.py +++ b/test/test-suite/test_arithmetic.py @@ -696,7 +696,8 @@ def test_find_trim(self): assert height == 60 test_rgb = test.bandjoin([test, test]) - left, top, width, height = test_rgb.find_trim(background=[255, 255, + left, top, width, height = test_rgb.find_trim(line_art=True, + background=[255, 255, 255]) assert left == 10 assert top == 20