From 5fd834980832bc875fe1aa83f5be20d587514a42 Mon Sep 17 00:00:00 2001 From: danblooomberg Date: Sat, 23 Sep 2023 21:30:12 -0700 Subject: [PATCH] Remove transparency layer if it exists in convertformat * Most formats don't support rgba; this prevents conversion failure. --- prog/convertformat.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/prog/convertformat.c b/prog/convertformat.c index 0e62ef007..78659959e 100644 --- a/prog/convertformat.c +++ b/prog/convertformat.c @@ -56,6 +56,8 @@ * WEBP .webp * JP2 .jp2 * + * If spp == 4 (rgba), the alpha component is removed, using a white backing. + * * If the requested output format does not support the image type, * the image is written in png format, with filename extension 'png'. */ @@ -73,7 +75,7 @@ int main(int argc, char *filein, *fileout, *base, *ext; const char *formatstr; l_int32 format, d, change; -PIX *pixs; +PIX *pixs, *pix1; if (argc != 3 && argc != 4) { lept_stderr("Syntax: convertformat filein fileout [format]\n" @@ -144,6 +146,9 @@ PIX *pixs; L_ERROR("read fail for %s\n", __func__, filein); return 1; } + pix1 = pixRemoveAlpha(pixs); + pixDestroy(&pixs); + pixs = pix1; /* Change output format if necessary */ change = FALSE;