Skip to content

Commit ca71066

Browse files
committed
Fix: bitmaps with BITMAPV3INFOHEADER cannot be imported
These files are reportedly written by Photoshop and based on a specification by Microsoft. More information can be found here: https://en.wikipedia.org/wiki/BMP_file_format#DIB_header_(bitmap_information_header) https://formats.kaitai.io/bmp/ https://web.archive.org/web/20150127132443/https://forums.adobe.com/message/3272950
1 parent ede8adb commit ca71066

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

ext/gd/libgd/bmp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ extern "C" {
2828
#define BMP_WINDOWS_V3 40
2929
#define BMP_OS2_V1 12
3030
#define BMP_OS2_V2 64
31+
#define BMP_WINDOWS_V3INFO 56
3132
#define BMP_WINDOWS_V4 108
3233
#define BMP_WINDOWS_V5 124
3334

ext/gd/libgd/gd_bmp.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,7 @@ static int bmp_read_info(gdIOCtx *infile, bmp_info_t *info)
545545
switch (info->len) {
546546
/* For now treat Windows v4 + v5 as v3 */
547547
case BMP_WINDOWS_V3:
548+
case BMP_WINDOWS_V3INFO:
548549
case BMP_WINDOWS_V4:
549550
case BMP_WINDOWS_V5:
550551
BMP_DEBUG(printf("Reading Windows Header\n"));
@@ -685,8 +686,12 @@ static int bmp_read_direct(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, b
685686
BMP_DEBUG(printf("Bitfield compression isn't supported for 24-bit\n"));
686687
return 1;
687688
}
688-
BMP_DEBUG(printf("Currently no bitfield support\n"));
689-
return 1;
689+
/* For 32 BPP images, the bitfields do not contain any useful information. They can be safely skipped. */
690+
if (info->depth != 32) {
691+
BMP_DEBUG(printf("Currently no bitfield support\n"));
692+
return 1;
693+
}
694+
690695
break;
691696

692697
case BMP_BI_RLE8:

0 commit comments

Comments
 (0)