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