Giter Site home page Giter Site logo

kobutri / dart_image_size_getter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from caijinglong/dart_image_size_getter

0.0 0.0 0.0 5.71 MB

Use dart file api to get image size, needn't use decode. just read the metadata.

License: Apache License 2.0

Dart 99.58% Shell 0.42%

dart_image_size_getter's Introduction

元数据总结

JPG

开头: 0xFF 0xD8 结尾: 0xFF 0xD9

数据块分析:

数值 偏移量 长度 说明
FF +0 1 开始标识符
任意 +1 1 类型,查看规范
n +2 ~ +3 2 块长度, 包含这两位, 但不包含 FF 和类型长度
内容 +4 ~ +(n+2) n-2 内容

已知类型标识符 |数值|说明|额外| |C0| 宽度高度|+5~+6 高度 +7~+8 宽度|

PNG

开头固定为:

89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52

宽度在 0x00000010 偏移量处, 0~3 位是宽度 4~7 位是高度

Webp

开头: 12 字节标识 webp 格式

20190920150556.png

RIFF(4 字节) + 文件长度(4 字节) + WEBP(4 字节), 文件长度不包含 RIFF 标识头和长度信息, 但包含 WEBP

比如我的图片文件大小为 125,198 字节, 这个文件长度对应的十六进制为 06 E9 01 00 , 这里要注意, 和 png jpg 的长度表示方案不同, 这里是倒序的 0x0001e906 = 125190


VP8 chunk: 找到 VP8 的标识 根据内容不同, 表示也不尽相同 往后偏移 +14 ~ +15 为宽度(倒序), 16~17为高度(倒序))

Gif

开头: 0x47, 0x49, 0x46, 0x38, 0x39, 0x61 结尾: 0x3B

从偏移量 +6~+7 两位标识宽度 +8~+9标识高度, 这里也是倒序, 示例中图片的宽度对应的十六进制为: [0xB0,0x02] (688), 高度为[0x2E,0x05](1326)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.