1b6cee71dSXin LI 2b6cee71dSXin LI#------------------------------------------------------------------------------ 3*898496eeSXin LI# $File: jpeg,v 1.38 2022/12/02 17:42:04 christos Exp $ 4b6cee71dSXin LI# JPEG images 5b6cee71dSXin LI# SunOS 5.5.1 had 6b6cee71dSXin LI# 7b6cee71dSXin LI# 0 string \377\330\377\340 JPEG file 8b6cee71dSXin LI# 0 string \377\330\377\356 JPG file 9b6cee71dSXin LI# 10b6cee71dSXin LI# both of which turn into "JPEG image data" here. 11b6cee71dSXin LI# 1243a5ec4eSXin LI0 belong 0xffd8fff7 JPEG-LS image data 1343a5ec4eSXin LI!:mime image/jls 1443a5ec4eSXin LI!:ext jls 1543a5ec4eSXin LI>0 use jpeg 1643a5ec4eSXin LI 1743a5ec4eSXin LI0 belong&0xffffff00 0xffd8ff00 JPEG image data 18b6cee71dSXin LI!:mime image/jpeg 19b6cee71dSXin LI!:apple 8BIMJPEG 205f0216bdSXin LI!:strength *3 215f0216bdSXin LI!:ext jpeg/jpg/jpe/jfif 2243a5ec4eSXin LI>0 use jpeg 2343a5ec4eSXin LI 2443a5ec4eSXin LI0 name jpeg 25b6cee71dSXin LI>6 string JFIF \b, JFIF standard 26b6cee71dSXin LI# The following added by Erik Rossen <rossen@freesurf.ch> 1999-09-06 27b6cee71dSXin LI# in a vain attempt to add image size reporting for JFIF. Note that these 28b6cee71dSXin LI# tests are not fool-proof since some perfectly valid JPEGs are currently 29b6cee71dSXin LI# impossible to specify in magic(4) format. 30b6cee71dSXin LI# First, a little JFIF version info: 31b6cee71dSXin LI>>11 byte x \b %d. 32b6cee71dSXin LI>>12 byte x \b%02d 33b6cee71dSXin LI# Next, the resolution or aspect ratio of the image: 34c2931133SXin LI>>13 byte 0 \b, aspect ratio 35c2931133SXin LI>>13 byte 1 \b, resolution (DPI) 36c2931133SXin LI>>13 byte 2 \b, resolution (DPCM) 37c2931133SXin LI>>14 beshort x \b, density %dx 38c2931133SXin LI>>16 beshort x \b%d 39c2931133SXin LI>>4 beshort x \b, segment length %d 40b6cee71dSXin LI# Next, show thumbnail info, if it exists: 41b6cee71dSXin LI>>18 byte !0 \b, thumbnail %dx 42b6cee71dSXin LI>>>19 byte x \b%d 434460e5b0SXin LI>6 string Exif \b, Exif standard: [ 444460e5b0SXin LI>>12 indirect/r x 454460e5b0SXin LI>>12 string x \b] 46c2931133SXin LI 47c2931133SXin LI# Jump to the first segment 48c2931133SXin LI>(4.S+4) use jpeg_segment 49c2931133SXin LI 50c2931133SXin LI# This uses recursion... 51c2931133SXin LI0 name jpeg_segment 52c2931133SXin LI>0 beshort 0xFFFE 535f0216bdSXin LI# Recursion handled by FFE0 545f0216bdSXin LI#>>(2.S+2) use jpeg_segment 55c2931133SXin LI>>2 pstring/HJ x \b, comment: "%s" 56c2931133SXin LI 57c2931133SXin LI>0 beshort 0xFFC0 58c2931133SXin LI>>(2.S+2) use jpeg_segment 59c2931133SXin LI>>4 byte x \b, baseline, precision %d 60c2931133SXin LI>>7 beshort x \b, %dx 61c2931133SXin LI>>5 beshort x \b%d 6248c779cdSXin LI>>9 byte x \b, components %d 63c2931133SXin LI 64c2931133SXin LI>0 beshort 0xFFC1 65c2931133SXin LI>>(2.S+2) use jpeg_segment 66c2931133SXin LI>>4 byte x \b, extended sequential, precision %d 67c2931133SXin LI>>7 beshort x \b, %dx 68c2931133SXin LI>>5 beshort x \b%d 6948c779cdSXin LI>>9 byte x \b, components %d 70c2931133SXin LI 71c2931133SXin LI>0 beshort 0xFFC2 72c2931133SXin LI>>(2.S+2) use jpeg_segment 73c2931133SXin LI>>4 byte x \b, progressive, precision %d 74c2931133SXin LI>>7 beshort x \b, %dx 75c2931133SXin LI>>5 beshort x \b%d 7648c779cdSXin LI>>9 byte x \b, components %d 77c2931133SXin LI 78c2931133SXin LI# Define Huffman Tables 79c2931133SXin LI>0 beshort 0xFFC4 80c2931133SXin LI>>(2.S+2) use jpeg_segment 81c2931133SXin LI 824460e5b0SXin LI>0 beshort 0xFFE1 835f0216bdSXin LI# Recursion handled by FFE0 844460e5b0SXin LI#>>(2.S+2) use jpeg_segment 854460e5b0SXin LI>>4 string Exif \b, Exif Standard: [ 864460e5b0SXin LI>>>10 indirect/r x 874460e5b0SXin LI>>>10 string x \b] 884460e5b0SXin LI 89c2931133SXin LI# Application specific markers 90c2931133SXin LI>0 beshort&0xFFE0 =0xFFE0 91c2931133SXin LI>>(2.S+2) use jpeg_segment 92c2931133SXin LI 93c2931133SXin LI# DB: Define Quantization tables 94c2931133SXin LI# DD: Define Restart interval [XXX: wrong here, it is 4 bytes] 95c2931133SXin LI# D8: Start of image 96c2931133SXin LI# D9: End of image 97c2931133SXin LI# Dn: Restart 98c2931133SXin LI>0 beshort&0xFFD0 =0xFFD0 995f0216bdSXin LI>>0 beshort&0xFFE0 !0xFFE0 1005f0216bdSXin LI>>>(2.S+2) use jpeg_segment 101b6cee71dSXin LI 10243a5ec4eSXin LI#>0 beshort x unknown %#x 1034460e5b0SXin LI#>>(2.S+2) use jpeg_segment 1044460e5b0SXin LI 105b6cee71dSXin LI# HSI is Handmade Software's proprietary JPEG encoding scheme 106a2dfb722SXin LI# Update: Joerg Jenderek 107a2dfb722SXin LI# URL: http://fileformats.archiveteam.org/wiki/HSI_JPEG 108a2dfb722SXin LI# Reference: http://mark0.net/download/triddefs_xml.7z/defs/b/bitmap-hsi1.trid.xml 109a2dfb722SXin LI# Note: called by TrID "HSI JPEG bitmap" 110b6cee71dSXin LI0 string hsi1 JPEG image data, HSI proprietary 111a2dfb722SXin LI#!:mime application/octet-stream 112a2dfb722SXin LI!:mime image/x-hsi 113a2dfb722SXin LI!:ext hsi/jpg 114b6cee71dSXin LI 115b6cee71dSXin LI# From: David Santinoli <david@santinoli.com> 116b6cee71dSXin LI0 string \x00\x00\x00\x0C\x6A\x50\x20\x20\x0D\x0A\x87\x0A JPEG 2000 117a2dfb722SXin LI# delete from ./animation (version 1.87) with jP (=6A50h) magic at offset 4 118b6cee71dSXin LI# From: Johan van der Knijff <johan.vanderknijff@kb.nl> 119b6cee71dSXin LI# Added sub-entries for JP2, JPX, JPM and MJ2 formats; added mimetypes 120b6cee71dSXin LI# https://github.com/bitsgalore/jp2kMagic 121b6cee71dSXin LI# 122b6cee71dSXin LI# Now read value of 'Brand' field, which yields a few possibilities: 123a2dfb722SXin LI# Update: Joerg Jenderek 124a2dfb722SXin LI# URL: http://fileformats.archiveteam.org/wiki/JP2 125a2dfb722SXin LI# Reference: http://mark0.net/download/triddefs_xml.7z/defs/b/bitmap-jpeg2k.trid.xml 126a2dfb722SXin LI# Note: called by TrID "JPEG 2000 bitmap" 127b6cee71dSXin LI>20 string \x6a\x70\x32\x20 Part 1 (JP2) 128a2dfb722SXin LI# aliases image/jpeg2000, image/jpeg2000-image, image/x-jpeg2000-image 129b6cee71dSXin LI!:mime image/jp2 130a2dfb722SXin LI!:ext jp2 131a2dfb722SXin LI# URL: http://fileformats.archiveteam.org/wiki/JPX 132a2dfb722SXin LI# Reference: http://mark0.net/download/triddefs_xml.7z/defs/b/bitmap-jpx.trid.xml 133a2dfb722SXin LI# Note: called by TrID "JPEG 2000 eXtended bitmap" 134b6cee71dSXin LI>20 string \x6a\x70\x78\x20 Part 2 (JPX) 135b6cee71dSXin LI!:mime image/jpx 136a2dfb722SXin LI!:ext jpf/jpx 137a2dfb722SXin LI# URL: http://fileformats.archiveteam.org/wiki/JPM 138a2dfb722SXin LI# Reference: http://mark0.net/download/triddefs_xml.7z/defs/b/bitmap-jpm.trid.xml 139a2dfb722SXin LI# Note: called by TrID "JPEG 2000 eXtended bitmap" 140b6cee71dSXin LI>20 string \x6a\x70\x6d\x20 Part 6 (JPM) 141b6cee71dSXin LI!:mime image/jpm 142a2dfb722SXin LI!:ext jpm 143a2dfb722SXin LI# URL: http://fileformats.archiveteam.org/wiki/MJ2 144a2dfb722SXin LI# Reference: http://mark0.net/download/triddefs_xml.7z/defs/v/video-mj2.trid.xml 145a2dfb722SXin LI# Note: called by TrID "Motion JPEG 2000 video" 146b6cee71dSXin LI>20 string \x6d\x6a\x70\x32 Part 3 (MJ2) 147b6cee71dSXin LI!:mime video/mj2 148a2dfb722SXin LI!:ext mj2/mjp2 149b6cee71dSXin LI 150b6cee71dSXin LI# Type: JPEG 2000 codesream 151b6cee71dSXin LI# From: Mathieu Malaterre <mathieu.malaterre@gmail.com> 152a2dfb722SXin LI# Update: Joerg Jenderek 153a2dfb722SXin LI# URL: http://fileformats.archiveteam.org/wiki/JPEG_2000_codestream 154a2dfb722SXin LI# Reference: http://mark0.net/download/triddefs_xml.7z/defs/b/bitmap-jpc.trid.xml 155a2dfb722SXin LI# Note: called by TrID "JPEG-2000 Code Stream bitmap" 156b6cee71dSXin LI0 belong 0xff4fff51 JPEG 2000 codestream 157a2dfb722SXin LI# value like: 0701h FF50h 158a2dfb722SXin LI#>45 ubeshort x \b, at 45 %#4.4x 159a2dfb722SXin LI#!:mime application/octet-stream 160a2dfb722SXin LI# https://reposcope.com/mimetype/image/x-jp2-codestream 161a2dfb722SXin LI!:mime image/x-jp2-codestream 162a2dfb722SXin LI!:ext jpc/j2c/j2k 163a2dfb722SXin LI# MAYBE also JHC like in byte_causal.jhc ? 164a2dfb722SXin LI# WHAT IS THAT? DEAD ENTRY? 165a2dfb722SXin LI#45 beshort 0xff52 166a5d223e6SXin LI 167a5d223e6SXin LI# JPEG extended range 168a2dfb722SXin LI# URL: http://fileformats.archiveteam.org/wiki/JPEG_XR 169a2dfb722SXin LI# Reference: https://www.itu.int/rec/T-REC-T.832 170a2dfb722SXin LI# http://mark0.net/download/triddefs_xml.7z/defs/b/bitmap-wmp.trid.xml 171a2dfb722SXin LI# Note: called by TrID "JPEG XR bitmap" 172a5d223e6SXin LI0 string \x49\x49\xbc 173a2dfb722SXin LI# FILE_VERSION_ID; shall be equal to 1; other values are reserved for future use 174a5d223e6SXin LI>3 byte 1 175a2dfb722SXin LI# FIRST_IFD_OFFSET; shall be an integer multiple of 2; so skip DROID fmt-590-signature-id-931.wdp 176a5d223e6SXin LI>>4 lelong%2 0 JPEG-XR 177a2dfb722SXin LI#!:mime image/vnd.ms-photo 178a5d223e6SXin LI!:mime image/jxr 179a2dfb722SXin LI# NO example for HDP ! 180a2dfb722SXin LI!:ext jxr/wdp/hdp 181a2dfb722SXin LI# MAYBE also WMP ? 182a2dfb722SXin LI#!:ext jxr/wdp/hdp/wmp 183a2dfb722SXin LI# moved from ./images (version 1.205 ), merged and 184a2dfb722SXin LI# partly verified by XnView `nconvert -info abydos.jxr FLOWER.wdp` 185a2dfb722SXin LI# example: https://web.archive.org/web/20160403012904/ 186a2dfb722SXin LI# http://shikino.co.jp/solution/upfile/FLOWER.wdp.zip 187a2dfb722SXin LI>90 bequad 0x574D50484F544F00 188a2dfb722SXin LI>>98 byte&0x08 =0x08 \b, hard tiling 189a2dfb722SXin LI>>99 byte&0x80 =0x80 \b, tiling present 190a2dfb722SXin LI>>99 byte&0x40 =0x40 \b, codestream present 191a2dfb722SXin LI>>99 byte&0x38 x \b, spatial xform= 192a2dfb722SXin LI>>99 byte&0x38 0x00 \bTL 193a2dfb722SXin LI>>99 byte&0x38 0x08 \bBL 194a2dfb722SXin LI>>99 byte&0x38 0x10 \bTR 195a2dfb722SXin LI>>99 byte&0x38 0x18 \bBR 196a2dfb722SXin LI>>99 byte&0x38 0x20 \bBT 197a2dfb722SXin LI>>99 byte&0x38 0x28 \bRB 198a2dfb722SXin LI>>99 byte&0x38 0x30 \bLT 199a2dfb722SXin LI>>99 byte&0x38 0x38 \bLB 200a2dfb722SXin LI>>100 byte&0x80 =0x80 \b, short header 201a2dfb722SXin LI>>>102 beshort+1 x \b, %d 202a2dfb722SXin LI>>>104 beshort+1 x \bx%d 203a2dfb722SXin LI>>100 byte&0x80 =0x00 \b, long header 204a2dfb722SXin LI>>>102 belong+1 x \b, %x 205a2dfb722SXin LI>>>106 belong+1 x \bx%x 206a2dfb722SXin LI>>101 beshort&0xf x \b, bitdepth= 207a2dfb722SXin LI>>>101 beshort&0xf 0x0 \b1-WHITE=1 208a2dfb722SXin LI>>>101 beshort&0xf 0x1 \b8 209a2dfb722SXin LI>>>101 beshort&0xf 0x2 \b16 210a2dfb722SXin LI>>>101 beshort&0xf 0x3 \b16-SIGNED 211a2dfb722SXin LI>>>101 beshort&0xf 0x4 \b16-FLOAT 212a2dfb722SXin LI>>>101 beshort&0xf 0x5 \b(reserved 5) 213a2dfb722SXin LI>>>101 beshort&0xf 0x6 \b32-SIGNED 214a2dfb722SXin LI>>>101 beshort&0xf 0x7 \b32-FLOAT 215a2dfb722SXin LI>>>101 beshort&0xf 0x8 \b5 216a2dfb722SXin LI>>>101 beshort&0xf 0x9 \b10 217a2dfb722SXin LI>>>101 beshort&0xf 0xa \b5-6-5 218a2dfb722SXin LI>>>101 beshort&0xf 0xb \b(reserved %d) 219a2dfb722SXin LI>>>101 beshort&0xf 0xc \b(reserved %d) 220a2dfb722SXin LI>>>101 beshort&0xf 0xd \b(reserved %d) 221a2dfb722SXin LI>>>101 beshort&0xf 0xe \b(reserved %d) 222a2dfb722SXin LI>>>101 beshort&0xf 0xf \b1-BLACK=1 223a2dfb722SXin LI>>101 beshort&0xf0 x \b, colorfmt= 224a2dfb722SXin LI>>>101 beshort&0xf0 0x00 \bYONLY 225a2dfb722SXin LI>>>101 beshort&0xf0 0x10 \bYUV240 226a2dfb722SXin LI>>>101 beshort&0xf0 0x20 \bYWV422 227a2dfb722SXin LI>>>101 beshort&0xf0 0x30 \bYWV444 228a2dfb722SXin LI>>>101 beshort&0xf0 0x40 \bCMYK 229a2dfb722SXin LI>>>101 beshort&0xf0 0x50 \bCMYKDIRECT 230a2dfb722SXin LI>>>101 beshort&0xf0 0x60 \bNCOMPONENT 231a2dfb722SXin LI>>>101 beshort&0xf0 0x70 \bRGB 232a2dfb722SXin LI>>>101 beshort&0xf0 0x80 \bRGBE 233a2dfb722SXin LI>>>101 beshort&0xf0 >0x80 \b(reserved %#x) 23443a5ec4eSXin LI 23543a5ec4eSXin LI# JPEG XL 23643a5ec4eSXin LI# From: Ian Tester 237a2dfb722SXin LI# Update: Joerg Jenderek 238a2dfb722SXin LI# URL: http://fileformats.archiveteam.org/wiki/JPEG_XL 239a2dfb722SXin LI# Reference: http://mark0.net/download/triddefs_xml.7z/defs/b/bitmap-jxl.trid.xml 240a2dfb722SXin LI# Note: called by TrID "JPEG XL bitmap" 24143a5ec4eSXin LI0 string \xff\x0a JPEG XL codestream 242*898496eeSXin LI!:mime image/jxl 24343a5ec4eSXin LI!:ext jxl 24443a5ec4eSXin LI 24543a5ec4eSXin LI# JPEG XL (transcoded JPEG file) 246a2dfb722SXin LI# Update: Joerg Jenderek 247a2dfb722SXin LI# URL: http://fileformats.archiveteam.org/wiki/JPEG_XL 248a2dfb722SXin LI# Reference: http://mark0.net/download/triddefs_xml.7z/defs/b/bitmap-jxl-iso.trid.xml 249a2dfb722SXin LI# Note: called by TrID "JPEG XL bitmap (ISOBMFF)" 25043a5ec4eSXin LI0 string \x00\x00\x00\x0cJXL\x20\x0d\x0a\x87\x0a JPEG XL container 251*898496eeSXin LI!:mime image/jxl 25243a5ec4eSXin LI!:ext jxl 253