gildas-lormeau/Polyglot-HTML-ZIP-PNG
소개
Learn How to Create HTML/ZIP/PNG Polyglot Files!
웹 및 앱 개발측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- +1
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalLearn How to Create HTML/ZIP/PNG Polyglot Files in JavaScript
Table of Contents
- Introduction
- Presentation
- TL;DR
- Viewing the Presentation in Chromium (and WebKit) Browsers
- Creation of Polyglot Files with SingleFile
- Known Issues
- Thank You
Introduction
Imagine a digital chameleon: a file that combines ZIP, HTML, and PNG into one versatile format. It can be displayed as a web page, unzipped to obtain all the page's resources, or viewed as an image.
Discover an innovative approach to sharing and storing web content, and learn how to create these polyglot files in JavaScript!
Presentation
You can view the web presentation in:
Press F1 during the presentation to see the keyboard shortcuts.
TL;DR
Resulting File
- download file: demo.png.zip.html
- view page: demo.png.zip.html
Summary
File Compatibility
This file and the presentation files are compatible with:
- HTML (displays the extracted page in no-quirks mode)
- ZIP (contains the displayed page and its resources) - rename the file to
.zipand view it with ZIP Manager - PNG - rename the file to
.pngand view it with PNG file chunk inpector
If you are intrigued or more curious, you can also view it with HexEd.it.
The presentation explains how to generate this file and the technical challenges involved.
Fun Fact
The image displayed at the center of the page demo.png.zip.html is the page itself, but interpreted as a PNG file (cf. the <img src="#" ...> tag).
Viewing the Presentation in Chromium (and WebKit) Browsers
You should install the extension from the zip file located in util/web-extension in order to add the support of file:// URIs in the Fetch API and run the first examples from the presentation.
Alternatively, you can view the examples via an HTTP server.
This issue is addressed in the subsequent examples of the presentation.
Creation of Polyglot Files with SingleFile
- from the browser
Install SingleFile, select in the options page File format > format > self-extracting ZIP (universal) and enable File format > format > embed image.
- from the command line interface
Install single-file-cli from NPM and run single-file as shown below.
npm install single-file-cli
npx single-file \
--compress-content \
--self-extracting-archive \
--embedded-image=./image.png \
--dump-content \
https://www.example.com > output.png.zip.html
Known Issues
- A bug in "Archive Utility" on macOS prevents it from decompressing the resulting file. You can use
unzipto get around this issue. - The HTML page cannot be viewed when opened from the filesystem on iOS because the page is displayed by default in a viewer which does not support JavaScript. Installing a third-party browser can help you get around this problem.
- Depending on the browser you're using, the presentation may be a little slow.
Thank You
This presentation is dedicated to my biggest supporter on this project. Many thanks @ljonathanl, we miss your enthusiasm and creativity.
관련 프로젝트 살펴보기
불러오는 중…