Skip to content

Commit

Permalink
Remove transparency layer if it exists in convertformat
Browse files Browse the repository at this point in the history
* Most formats don't support rgba; this prevents conversion failure.
  • Loading branch information
DanBloomberg committed Sep 24, 2023
1 parent 01aebf2 commit 5fd8349
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion prog/convertformat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
*/
Expand All @@ -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"
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 5fd8349

Please sign in to comment.