From b3ff4d9ed61f064df39716de7ebaa799a7abd2f5 Mon Sep 17 00:00:00 2001 From: Moggers Date: Sun, 14 Nov 2021 14:04:32 +1000 Subject: [PATCH] Implement Header Sniffing For Magickload Tga (#2533) Add TGA sniffing --- libvips/foreign/magick.c | 28 ++++++++++++++++++--- test/test-suite/helpers/helpers.py | 2 ++ test/test-suite/images/silicongraphics.sgi | Bin 0 -> 27828 bytes test/test-suite/images/targa.tga | Bin 0 -> 10873 bytes test/test-suite/test_foreign.py | 18 ++++++++++++- 5 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 test/test-suite/images/silicongraphics.sgi create mode 100644 test/test-suite/images/targa.tga diff --git a/libvips/foreign/magick.c b/libvips/foreign/magick.c index f4a5eab0..75ef879d 100644 --- a/libvips/foreign/magick.c +++ b/libvips/foreign/magick.c @@ -52,12 +52,24 @@ #if defined(HAVE_MAGICK6) || defined(HAVE_MAGICK7) -/* ImageMagick can't detect some formats, like ICO, by examining the contents -- - * ico.c simply does not have a recogniser. +/* ImageMagick can't detect some formats, like ICO and TGA, by examining the contents -- + * ico.c and tga.c simply do not have recognisers. * * For these formats, do the detection ourselves. - * * Return an IM format specifier, or NULL to let IM do the detection. + * + * For sniffing TGAs, we check that there is at least enough room for the header and that + * the preamble contains valid values: + * ----------------------------------------------------------- + * |0x00 | 0-255 idlength, skip | + * |0x01 | 0-1, color map present | + * |0x02 | Any of (0, 1, 2, 3, 9, 10, 11), Image type | + * ----------------------------------------------------------- + * + * References: + * * https://www.dca.fee.unicamp.br/~martino/disciplinas/ea978/tgaffs.pdf + * * http://www.paulbourke.net/dataformats/tga/ + * * https://en.wikipedia.org/wiki/Truevision_TGA#Technical_details */ static const char * magick_sniff( const unsigned char *bytes, size_t length ) @@ -68,6 +80,16 @@ magick_sniff( const unsigned char *bytes, size_t length ) bytes[2] == 1 && bytes[3] == 0 ) return( "ICO" ); + if( length >= 18 && + (bytes[1] == 0 || bytes[1] == 1) && ( + bytes[2] == 0 || + bytes[2] == 1 || + bytes[2] == 2 || + bytes[2] == 3 || + bytes[2] == 9 || + bytes[2] == 10 || + bytes[2] == 11) ) + return( "TGA" ); return( NULL ); } diff --git a/test/test-suite/helpers/helpers.py b/test/test-suite/helpers/helpers.py index 0fa2bab6..c754d06d 100644 --- a/test/test-suite/helpers/helpers.py +++ b/test/test-suite/helpers/helpers.py @@ -41,6 +41,8 @@ DICOM_FILE = os.path.join(IMAGES, "dicom_test_image.dcm") BMP_FILE = os.path.join(IMAGES, "MARBLES.BMP") NIFTI_FILE = os.path.join(IMAGES, "avg152T1_LR_nifti.nii.gz") ICO_FILE = os.path.join(IMAGES, "favicon.ico") +TGA_FILE = os.path.join(IMAGES, "targa.tga") +SGI_FILE = os.path.join(IMAGES, "silicongraphics.sgi") AVIF_FILE = os.path.join(IMAGES, "avif-orientation-6.avif") HEIC_FILE = os.path.join(IMAGES, "heic-orientation-6.heic") RGBA_FILE = os.path.join(IMAGES, "rgba.png") diff --git a/test/test-suite/images/silicongraphics.sgi b/test/test-suite/images/silicongraphics.sgi new file mode 100644 index 0000000000000000000000000000000000000000..cf29abd117e1a87f3405f2209c7c6e925241f038 GIT binary patch literal 27828 zcmeI33wT^rwfJ{CY0{(*TG~R}q)pSjGkK?JNSZXy(?`;#Nt-tBq>r?xv_&k)r4%@N zCXFJ#A6G=htAqBGB0~fPxqyNKI-uYKR0N*{9lT;L%0u*e=l@%0&*|{>YZ3qVUcS%I z==aM$XP>q9T6^ua_c}8jru}5vH07K2#c5wuKBfN`jkQzFKScx%U9Z$33--VUD1vj9 zI`|4a4fn%wcn`c4wnGi1LxNHVo`Xl>cKA444ZC4I6vBL^E_@lDg8Sg}a4lR6T~H0n zf&AMaf$zX=a2;F)yI>voVV+XvOYjr;8hj4k4R3*MZ~-iX=}PVU4SXBE2p@whVJ8?+ z0Ou&R_eFRTz6v+OHE-f@I&}AU~l+RV1C18Ks<*gf%O}@1>OtT8EOUQH8fMHLEM#o<8|B* z$KgG|JUZ~FgE(}gLxNIUn9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<2KWmJ0t zJDkeskRD-&Ss5DABkV9L!$W$6UZ*s=Qw#K(rJ)LZfbu`?XRi*HMPI^C-tei R%)fw7orhEB;op58{y%=Y+6({y literal 0 HcmV?d00001 diff --git a/test/test-suite/images/targa.tga b/test/test-suite/images/targa.tga new file mode 100644 index 0000000000000000000000000000000000000000..4451878371d7beb769a7bbde6151b078266eafe9 GIT binary patch literal 10873 zcmeI0TZ~<07034;l!PWGCdPyZeIfdwMosj=#Kgn|3k(;DR+I-HOptH{5eS+P5~4HH zPD@Lvt!<|l7>8+R=1hl~-fK%KZKoILz4QX~!t@H1SP>L2pjiLEwbysfIy*z~#RScn zWY5~)TL1O`)>_~CzPku6K0b95?IH?1$!lXr2en z^RW3m_;5TA-_)~t)~=CDuZ3syIo)?l_e#)>>AqjOvq5)U_e0X13A&ebzg)UgL3dR5 zYovQQ=nm_Cy>usn?vU;`lyuKaw^2IgN_nV|U7IX)6zgarwPq^`P`(@uM+=~IX zPxqta=(b7sLJ3#a?Uj9d2{)c@k8nGMqZTQ?@pQXoe@?g~0r!5oUBXev#0T!btsBrB zvsaw|?~!h*V~~uO1x%0b zmq<6oF-XRP0rOkk_e$NkhT%qHnNoCnF6^C$H=82WpP zV~~u?n5U%cbPSSl#Be^azaDlBl5spAIEz+G$2moPkc{J5MBlQ%XGpRZNXA2wDP}O7 z51fgt=`0^d4C^~03}NT8#!Ziw)WG5;zWvtPSaTl`a>{}!iKee^UV zX=M|_Y_(B5b2!W4;!Mq2F8gSk9Eun!RnD5EgAW^H(@(5a!6h9tzyn{(EydU_H|$7w z;yA{_SsQI-EN4%4!%vqb{tv=))`Pbk2Yz?7?3Z1A`w}oQF7uHdo!xs*@A~hU%$Z$2 z;p3L~m7n=K&nM+s?Je;zMsIfE3@<-&NL)O(s1ffm+2_7-8*>)AO4Zh1D;Hy9C5yhO zRKa1xuMdCa$y|v$`@t`kr~1$xhVk`f4XJHfTcp{AgOfF>@$5eGYRVbgH2k#o7Bf9S z3}5(W#rPy`9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2rmX$>u~{$zJf+KPPdl_IqS<|WG&{yo2XW7}qB*uY pH0#mqhvt6x|2z-$v2TCh`|d3hzu!8k_2zGX@z!fvZ=Cq0?B9LpofZH9 literal 0 HcmV?d00001 diff --git a/test/test-suite/test_foreign.py b/test/test-suite/test_foreign.py index 29f0889a..ebdf944a 100644 --- a/test/test-suite/test_foreign.py +++ b/test/test-suite/test_foreign.py @@ -10,7 +10,7 @@ from helpers import \ JPEG_FILE, SRGB_FILE, MATLAB_FILE, PNG_FILE, TIF_FILE, OME_FILE, \ ANALYZE_FILE, GIF_FILE, WEBP_FILE, EXR_FILE, FITS_FILE, OPENSLIDE_FILE, \ PDF_FILE, SVG_FILE, SVGZ_FILE, SVG_GZ_FILE, GIF_ANIM_FILE, DICOM_FILE, \ - BMP_FILE, NIFTI_FILE, ICO_FILE, AVIF_FILE, TRUNCATED_FILE, \ + BMP_FILE, NIFTI_FILE, ICO_FILE, TGA_FILE, SGI_FILE, AVIF_FILE, TRUNCATED_FILE, \ GIF_ANIM_EXPECTED_PNG_FILE, GIF_ANIM_DISPOSE_BACKGROUND_FILE, \ GIF_ANIM_DISPOSE_BACKGROUND_EXPECTED_PNG_FILE, \ GIF_ANIM_DISPOSE_PREVIOUS_FILE, \ @@ -664,6 +664,22 @@ class TestForeign: assert im.width == 16 assert im.height == 16 + # libvips has its own sniffer for TGA, test that + with open(TGA_FILE, 'rb') as f: + buf = f.read() + im = pyvips.Image.new_from_buffer(buf, "") + assert im.width == 433 + assert im.height == 433 + + # Test SGI/RGB files to sanity check that sniffers + # aren't too broad + with open(SGI_FILE, 'rb') as f: + buf = f.read() + im = pyvips.Image.new_from_buffer(buf, "") + assert im.width == 433 + assert im.height == 433 + + # load should see metadata like eg. icc profiles im = pyvips.Image.magickload(JPEG_FILE) assert len(im.get("icc-profile-data")) == 564