jpeg (267897) | jpeg (275698) |
---|---|
1 2#------------------------------------------------------------------------------ | 1 2#------------------------------------------------------------------------------ |
3# $File: jpeg,v 1.19 2013/02/04 15:50:03 christos Exp $ | 3# $File: jpeg,v 1.21 2014/09/12 20:47:00 christos Exp $ |
4# JPEG images 5# SunOS 5.5.1 had 6# 7# 0 string \377\330\377\340 JPEG file 8# 0 string \377\330\377\356 JPG file 9# 10# both of which turn into "JPEG image data" here. 11# --- 5 unchanged lines hidden (view full) --- 17# The following added by Erik Rossen <rossen@freesurf.ch> 1999-09-06 18# in a vain attempt to add image size reporting for JFIF. Note that these 19# tests are not fool-proof since some perfectly valid JPEGs are currently 20# impossible to specify in magic(4) format. 21# First, a little JFIF version info: 22>>11 byte x \b %d. 23>>12 byte x \b%02d 24# Next, the resolution or aspect ratio of the image: | 4# JPEG images 5# SunOS 5.5.1 had 6# 7# 0 string \377\330\377\340 JPEG file 8# 0 string \377\330\377\356 JPG file 9# 10# both of which turn into "JPEG image data" here. 11# --- 5 unchanged lines hidden (view full) --- 17# The following added by Erik Rossen <rossen@freesurf.ch> 1999-09-06 18# in a vain attempt to add image size reporting for JFIF. Note that these 19# tests are not fool-proof since some perfectly valid JPEGs are currently 20# impossible to specify in magic(4) format. 21# First, a little JFIF version info: 22>>11 byte x \b %d. 23>>12 byte x \b%02d 24# Next, the resolution or aspect ratio of the image: |
25#>>13 byte 0 \b, aspect ratio 26#>>13 byte 1 \b, resolution (DPI) 27#>>13 byte 2 \b, resolution (DPCM) 28#>>4 beshort x \b, segment length %d | 25>>13 byte 0 \b, aspect ratio 26>>13 byte 1 \b, resolution (DPI) 27>>13 byte 2 \b, resolution (DPCM) 28>>14 beshort x \b, density %dx 29>>16 beshort x \b%d 30>>4 beshort x \b, segment length %d |
29# Next, show thumbnail info, if it exists: 30>>18 byte !0 \b, thumbnail %dx 31>>>19 byte x \b%d 32 33# EXIF moved down here to avoid reporting a bogus version number, 34# and EXIF version number printing added. 35# - Patrik R=E5dman <patrik+file-magic@iki.fi> 36>6 string Exif \b, EXIF standard --- 79 unchanged lines hidden (view full) --- 116>>>>>(138.L+73) byte !0x30 \b%c 117# IFD 0 Entry #11 118>>>142 beshort 0x8769 119# EXIF IFD Entry #4: 120>>>>(150.L+50) beshort 0x9000 121>>>>>(150.L+59) byte x %c 122>>>>>(150.L+60) byte x \b.%c 123>>>>>(150.L+61) byte !0x30 \b%c | 31# Next, show thumbnail info, if it exists: 32>>18 byte !0 \b, thumbnail %dx 33>>>19 byte x \b%d 34 35# EXIF moved down here to avoid reporting a bogus version number, 36# and EXIF version number printing added. 37# - Patrik R=E5dman <patrik+file-magic@iki.fi> 38>6 string Exif \b, EXIF standard --- 79 unchanged lines hidden (view full) --- 118>>>>>(138.L+73) byte !0x30 \b%c 119# IFD 0 Entry #11 120>>>142 beshort 0x8769 121# EXIF IFD Entry #4: 122>>>>(150.L+50) beshort 0x9000 123>>>>>(150.L+59) byte x %c 124>>>>>(150.L+60) byte x \b.%c 125>>>>>(150.L+61) byte !0x30 \b%c |
124# Here things get sticky. We can do ONE MORE marker segment with 125# indirect addressing, and that's all. It would be great if we could 126# do pointer arithemetic like in an assembler language. Christos? 127# And if there was some sort of looping construct to do searches, plus a few 128# named accumulators, it would be even more effective... 129# At least we can show a comment if no other segments got inserted before: 130>(4.S+5) byte 0xFE \b, comment: 131>>(4.S+6) pstring/HJ x "%s" 132# Or, we can show the encoding type (I've included only the three most common) 133# and image dimensions if we are lucky and the SOFn (image segment) is here: 134>(4.S+5) byte 0xC0 \b, baseline 135>>(4.S+6) byte x \b, precision %d 136>>(4.S+7) beshort x \b, %dx 137>>(4.S+9) beshort x \b%d 138>(4.S+5) byte 0xC1 \b, extended sequential 139>>(4.S+6) byte x \b, precision %d 140>>(4.S+7) beshort x \b, %dx 141>>(4.S+9) beshort x \b%d 142>(4.S+5) byte 0xC2 \b, progressive 143>>(4.S+6) byte x \b, precision %d 144>>(4.S+7) beshort x \b, %dx 145>>(4.S+9) beshort x \b%d 146# I've commented-out quantisation table reporting. I doubt anyone cares yet. 147#>(4.S+5) byte 0xDB \b, quantisation table 148#>>(4.S+6) beshort x \b length=%d 149#>14 beshort x \b, %d x 150#>16 beshort x \b %d | |
151 | 126 |
127# Jump to the first segment 128>(4.S+4) use jpeg_segment 129 130# This uses recursion... 1310 name jpeg_segment 132>0 beshort 0xFFFE 133>>(2.S+2) use jpeg_segment 134>>2 pstring/HJ x \b, comment: "%s" 135 136>0 beshort 0xFFC0 137>>(2.S+2) use jpeg_segment 138>>4 byte x \b, baseline, precision %d 139>>7 beshort x \b, %dx 140>>5 beshort x \b%d 141>>9 byte x \b, frames %d 142 143>0 beshort 0xFFC1 144>>(2.S+2) use jpeg_segment 145>>4 byte x \b, extended sequential, precision %d 146>>7 beshort x \b, %dx 147>>5 beshort x \b%d 148>>9 byte x \b, frames %d 149 150>0 beshort 0xFFC2 151>>(2.S+2) use jpeg_segment 152>>4 byte x \b, progressive, precision %d 153>>7 beshort x \b, %dx 154>>5 beshort x \b%d 155>>9 byte x \b, frames %d 156 157# Define Huffman Tables 158>0 beshort 0xFFC4 159>>(2.S+2) use jpeg_segment 160 161# Application specific markers 162>0 beshort&0xFFE0 =0xFFE0 163>>(2.S+2) use jpeg_segment 164 165# DB: Define Quantization tables 166# DD: Define Restart interval [XXX: wrong here, it is 4 bytes] 167# D8: Start of image 168# D9: End of image 169# Dn: Restart 170>0 beshort&0xFFD0 =0xFFD0 171>>(2.S+2) use jpeg_segment 172 |
|
152# HSI is Handmade Software's proprietary JPEG encoding scheme 1530 string hsi1 JPEG image data, HSI proprietary 154 155# From: David Santinoli <david@santinoli.com> 1560 string \x00\x00\x00\x0C\x6A\x50\x20\x20\x0D\x0A\x87\x0A JPEG 2000 157# From: Johan van der Knijff <johan.vanderknijff@kb.nl> 158# Added sub-entries for JP2, JPX, JPM and MJ2 formats; added mimetypes 159# https://github.com/bitsgalore/jp2kMagic --- 15 unchanged lines hidden --- | 173# HSI is Handmade Software's proprietary JPEG encoding scheme 1740 string hsi1 JPEG image data, HSI proprietary 175 176# From: David Santinoli <david@santinoli.com> 1770 string \x00\x00\x00\x0C\x6A\x50\x20\x20\x0D\x0A\x87\x0A JPEG 2000 178# From: Johan van der Knijff <johan.vanderknijff@kb.nl> 179# Added sub-entries for JP2, JPX, JPM and MJ2 formats; added mimetypes 180# https://github.com/bitsgalore/jp2kMagic --- 15 unchanged lines hidden --- |