惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

B
Blog
V
Vulnerabilities – Threatpost
Apple Machine Learning Research
Apple Machine Learning Research
V
V2EX
博客园 - 叶小钗
阮一峰的网络日志
阮一峰的网络日志
人人都是产品经理
人人都是产品经理
Latest news
Latest news
博客园 - 三生石上(FineUI控件)
美团技术团队
aimingoo的专栏
aimingoo的专栏
Google Online Security Blog
Google Online Security Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
T
Threatpost
Y
Y Combinator Blog
T
Tailwind CSS Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
A
Arctic Wolf
C
Cyber Attacks, Cyber Crime and Cyber Security
小众软件
小众软件
Recent Commits to openclaw:main
Recent Commits to openclaw:main
T
Tenable Blog
W
WeLiveSecurity
L
LINUX DO - 热门话题
D
Docker
Cyberwarzone
Cyberwarzone
量子位
A
About on SuperTechFans
The Last Watchdog
The Last Watchdog
雷峰网
雷峰网
C
CERT Recently Published Vulnerability Notes
P
Palo Alto Networks Blog
The Hacker News
The Hacker News
Blog — PlanetScale
Blog — PlanetScale
P
Proofpoint News Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
F
Full Disclosure
The Cloudflare Blog
T
The Blog of Author Tim Ferriss
T
The Exploit Database - CXSecurity.com
Engineering at Meta
Engineering at Meta
O
OpenAI News
Hacker News - Newest:
Hacker News - Newest: "LLM"
Scott Helme
Scott Helme
IT之家
IT之家
S
Secure Thoughts
MongoDB | Blog
MongoDB | Blog
L
Lohrmann on Cybersecurity
博客园 - 司徒正美
Google DeepMind News
Google DeepMind News

vivaxy's Blog

SameSite Cookies 解读 - vivaxy's Blog VSCode Conventional Commits 插件 - vivaxy's Blog VSCode Conventional Commits Extension - vivaxy's Blog How Babel Is Built - vivaxy's Blog 一步一步解码 PNG 图片 - vivaxy's Blog Babel 的工程化实现 - vivaxy's Blog 浏览器图像转换手册 - vivaxy's Blog Decoding A PNG Image with JavaScript Step by Step Use npm Registry to Restric Installing Client Alfred 4 Workflow Open in VSCode Git Tag And Push Git Tag 基于 Custom Elements 的组件化开发 - vivaxy's Blog JavaScript PNG 图片编码和解码 - vivaxy's Blog 如何在多个模块中共享异步数据 - vivaxy's Blog JavaScript 函数式编程初窥 - vivaxy's Blog 用纯 CSS 实现弹窗 - vivaxy's Blog 在浏览器中使用 JavaScript 模块 - vivaxy's Blog Karabiner Elements Hyper 改键设置 - vivaxy's Blog Levenshtein 距离 - vivaxy's Blog Levenshtein 距离 - vivaxy's Blog
Comprehensive Image Processing on Browsers
vivaxy · 2019-11-06 · via vivaxy's Blog

Images can be represented in different types. They can be summarized as 5 types: DOM, URL, File, ImageData and Buffer.

Image Data Types

DOM

<img>

<img> elements load images from URL(e.g. Data URLs, HTTP URLs or Object URLs).

<canvas>

<canvas> elements draw images by canvas API drawImage from <img> elements.

URL

Data URLs

Data URLs carries base64 encoded image data. Image binary can be decoded from Data URLs. Data URL image file size is a little larger than the original binary data.

HTTP URLs

HTTP URLs represent images stored on servers. HTTP URLs are used to fetch image data from servers.

Object URLs

Object URLs represent the File or Blob object. Object URLs can be created by createObjectURL API, and released by revokeObjectURL API. The object is stored in browser memory and can be accessed by a short Object URL.

File

Blob

A Blob object represents a file-like object of binary data. It contains a readyonly size property and a readyonly type property. You can retrieve the binary data by slice, stream, text and arrayBuffer methods.

File

A File object is a special Blob object. In addtion to the Blob properties and methods, the File object contains lastModified, name properties.

ImageData

A ImageData object is a JavaScript object containing width, height and data properties, represents the image width, height and pixel data. data property is an one-dimensional array, containing data like [R, G, B, A, R, G, B, A]. Each [R, G, B, A] represents a pixel. You can create a ImageData by <canvas> API createImageData or the ImageData constructor.

Buffer

ArrayBuffer

There is only one way of accessing the binary data on browsers ArrayBuffer. An ArrayBuffer represents a raw binary data buffer of the image. ArrayBuffer cannot be read and written. You can only convert an ArrayBuffer to DataView or TypedArray to read and write binary data.

Buffer

In Node.js, Buffer is a special Uint8Array with some optimizations.

Convert within ArrayBuffer, DataView, TypedArray and Buffer

How to convert within `ArrayBuffer`, `DataView`, TypedArray and `Buffer`

Conver within DOM, URL, File, ImageData and Buffer

How to conver within DOM, URL, File, `ImageData` and Buffer

Reference