【问题标题】:iPhone JPG image has non-standard magic bytes ff d8 ff e1?iPhone JPG 图像有非标准的魔术字节 ff d8 ff e1?
【发布时间】:2010-12-30 19:36:25
【问题描述】:

在接受上传的图片之前,我的网络应用会根据文件扩展名检查前四个字节。一位同事向我展示了他的 iPhone 中被拒绝的图像。它们有不同的第四个字节(e1 = 225 而不是预期的 e0 = 224)。

这对 iPhone 来说很常见吗? JPG 文件中是否还使用了其他可能的魔术字节字符串?

编辑:发现这个有用的列表:http://www.garykessler.net/library/file_sigs.html

【问题讨论】:

    标签: iphone jpeg image-manipulation magic-numbers


    【解决方案1】:

    FF 总是标识一个“标记”——由于我目前正在编写一个 javascript 文件标识符,我将尝试用我的 JPEG javascript 对象来回答...

    已经给出了基本答案(已接受的答案),但这更详细地说明了如何检查不同的应用标记(带有后备)。顺便说一句: 到目前为止,JFIF、EXIF、Adobe、佳能和三星都有特殊的 APP0(但我们不知道未来)。所以js对象的逻辑是:

    如果其中一个 SPECS[x].regex 匹配,则获胜(第一个获胜)。但如果没有匹配,则父对象(仅 FFd8)获胜。

    SPECS 对象提供根据 PRONOM 标识符 - 您可以这样查看它们

    'http://apps.nationalarchives.gov.uk/pronom/fmt/'.concat(PUID) [官方] 'http://apps.nationalarchives.gov.uk/pronom/x-fmt/'.concat(xPUID) [实验性]

    _FFD8: { 
        SPECS: [
            { 
                PUID: 112, 
                regex: /^FFD8FFE8(.{2})53504946460001/, 
                desc: 'jpeg: Still Picture Interchange Format file (SPIF)',
                regexCapture: [
                    { key: 'recordedSignature' }, 
                    { key: 'segmentLength', fn: function(h){ return { value:parseInt(h, 16), _val:h.toString() }; } }
                ], 
                valueCapture: {
                    version: '1.00'
                }
            }, 
            { 
                PUID: 44, 
                regex: /^FFD8FFE0(.{2})4A464946000102/, 
                desc: 'jpeg: JPEG File Interchange Format file (JFIF), v. 1.02',
                regexCapture: [
                    { key: 'recordedSignature' }, 
                    { key: 'segmentLength', fn: function(h){ return { value:parseInt(h, 16), _val:h.toString() }; } }
                ], 
                valueCapture: {
                    version: '1.02',
                }
            },
            { 
                PUID: 43, 
                regex: /^FFD8FFE0(.{2})4A464946000101/, 
                desc: 'jpeg: JPEG File Interchange Format file (JFIF), v. 1.01',
                regexCapture: [
                    { key: 'recordedSignature' }, 
                    { key: 'segmentLength', fn: function(h){ return { value:parseInt(h, 16), _val:h.toString() }; } }
                ], 
                valueCapture: {
                    version: '1.01',
                }
            },
            { 
                PUID: 42, 
                regex: /^FFD8FFE0(.{2})4A464946000100/, 
                desc: 'jpeg: JPEG File Interchange Format file (JFIF), v. 1.00',
                regexCapture: [
                    { key: 'recordedSignature' }, 
                    { key: 'segmentLength', fn: function(h){ return { value:parseInt(h, 16), _val:h.toString() }; } }
                ], 
                valueCapture: {
                    version: '1.00',
                }
            },          
            { 
                PUID: 41, 
                xPUID: 398,
                regex: /^FFD8FFE1(.{2})45786966000049492A00(.+)009007000400000030323030/, 
                desc: 'jpeg: JPG Image File, using Exchangeable Image File Format (Exif), little endian, v. 2.0',
                regexCapture: [
                    { key: 'recordedSignature' }, 
                    { key: 'segmentLength', fn: function(h){ return { value:parseInt(h, 16), _val:h.toString() }; } }
                ], 
                valueCapture: {
                    endian: 'little',
                    version: '2.0',
                }
            }, 
            { 
                PUID: 41, 
                xPUID: 398, 
                regex: /^FFD8FFE1(.{2})4578696600004D4D002A(.+)900000070000000430323030/, 
                desc: 'jpeg: JPG Image File, using Exchangeable Image File Format (Exif), big endian, v. 2.0',
                regexCapture: [
                    { key: 'recordedSignature' }, 
                    { key: 'segmentLength', fn: function(h){ return { value:parseInt(h, 16), _val:h.toString() }; } }
                ], 
                valueCapture: {
                    endian: 'big',
                    version: '2.0',
                }
            },              
            { 
                PUID: 41, 
                xPUID: 390,
                regex: /^FFD8FFE1(.{2})45786966000049492A00(.+)009007000400000030323130/, 
                desc: 'jpeg: JPG Image File, using Exchangeable Image File Format (Exif), little endian, v. 2.1',
                regexCapture: [
                    { key: 'recordedSignature' }, 
                    { key: 'segmentLength', fn: function(h){ return { value:parseInt(h, 16), _val:h.toString() }; } }
                ], 
                valueCapture: {
                    endian: 'little',
                    version: '2.1',
                }
            }, 
            { 
                PUID: 41, 
                xPUID: 390, 
                regex: /^FFD8FFE1(.{2})4578696600004D4D002A(.+)900000070000000430323130/, 
                desc: 'jpeg: JPG Image File, using Exchangeable Image File Format (Exif), big endian, v. 2.1',
                regexCapture: [
                    { key: 'recordedSignature' }, 
                    { key: 'segmentLength', fn: function(h){ return { value:parseInt(h, 16), _val:h.toString() }; } }
                ], 
                valueCapture: {
                    endian: 'big',
                    version: '2.1',
                }
            },          
            { 
                PUID: 41, 
                xPUID: 391,
                regex: /^FFD8FFE1(.{2})45786966000049492A00(.+)009007000400000030323230/, 
                desc: 'jpeg: JPG Image File, using Exchangeable Image File Format (Exif), little endian, v. 2.2',
                regexCapture: [
                    { key: 'recordedSignature' }, 
                    { key: 'segmentLength', fn: function(h){ return { value:parseInt(h, 16), _val:h.toString() }; } }
                ], 
                valueCapture: {
                    endian: 'little',
                    version: '2.2',
                }
            }, 
            { 
                PUID: 41, 
                xPUID: 391, 
                regex: /^FFD8FFE1(.{2})4578696600004D4D002A(.+)900000070000000430323230/, 
                desc: 'jpeg: JPG Image File, using Exchangeable Image File Format (Exif), big endian, v. 2.2',
                regexCapture: [
                    { key: 'recordedSignature' }, 
                    { key: 'segmentLength', fn: function(h){ return { value:parseInt(h, 16), _val:h.toString() }; } }
                ], 
                valueCapture: {
                    endian: 'big',
                    version: '2.2',
                }
            }, 
            // specific JPEG (all begin with FFD8FF, map them to PUID 41)
            { 
                PUID: 41, 
                regex: /^FFD8FFED/, 
                desc: 'jpeg: JPG Image File, Adobe JPEG, Photoshop CMYK buffer'
            }, 
            { 
                PUID: 41, 
                regex: /^FFD8FFE2/, 
                desc: 'jpeg: JPG Image File, Canon JPEG, Canon EOS-1D'
            }, 
            { 
                PUID: 41, 
                regex: /^FFD8FFE3/, 
                desc: 'jpeg: JPG Image File, Samsung JPEG, e.g. Samsung D500'
            }, 
            { 
                PUID: 41, 
                regex: /^FFD8FFDB/, 
                desc: 'jpeg: JPG Image File, Samsung JPEG, e.g. Samsung D807'
            }
        ],
        ext: ['JPG', 'JPE', 'JPEG', 'SPF', 'SPIFF'],
        signature: [ 255, 216 ],
        desc: 'jpeg: JPEG File Interchange Format file, App0 marker not known',
        mime: 'image/jpeg',
        specifications: [
            { text:'Specification for the JFIF file format', href:'http://www.w3.org/Graphics/JPEG/jfif3.pdf', type:'W3', format:'pdf' },
            { text:'The JPEG compression specification', href:'http://www.w3.org/Graphics/JPEG/itu-t81.pdf', type:'W3', format:'pdf' },
            { text:'Exchangeable image file format for digital still cameras', href:'http://home.jeita.or.jp/tsc/std-pdf/CP3451C.pdf', type:'vendor', format:'pdf' }
        ], 
        references: [
            { text:'JPEG JFIF W3 Info', href:'http://www.w3.org/Graphics/JPEG/', type:'W3', format:'html' },
            { text:'JPEG.org', href:'http://www.jpeg.org/', type:'info', format:'html' },
            { text:'JPEG Exif App markers', href:'http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/JPEG.html', type:'info', format:'html'}
        ]
    }
    

    【讨论】:

      【解决方案2】:

      这似乎是一个完全有效的 JPEG 变体,according to Google

      【讨论】:

        【解决方案3】:

        它们似乎以某种方式表示 JPEG 的一个子类别。我发现 FF D8 FF E0 魔法表示“JFIF JPEG”,而 FF D8 FF E1 表示“EXIF JPEG”。

        编辑:在 google 缓存中找到这个:http://tinyurl.com/ydtjpjw(很有趣,因为它表明三星还有更多变体)

        【讨论】:

        • 链接已失效。短链接也因无法验证而被禁止
        • @phuclv 您确实看到线程的日期几乎是 12 年前,甚至在您加入 SO 之前?当时它并没有被禁止,我相信如果你在帖子中搜索魔法字节,现在你可以找到更好的链接,如果它仍然是一个问题的话。
        猜你喜欢
        • 2011-03-31
        • 2014-03-12
        • 1970-01-01
        • 1970-01-01
        • 2011-07-06
        • 2021-04-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多