zip-data-in-png
v1.1.1
Published
tweetable-polyglot-png in node.js
Downloads
1
Readme
tweetable-polyglot-png in js
Pack up to 3MB of data into a tweetable PNG polyglot file but in nodejs.
Original Repo: https://github.com/DavidBuchanan314/tweetable-polyglot-png
Install
yarn add zip-data-in-png
npm i zip-data-in-png
Status
Currently in beta, please do not use it in productions.
Features
- Fully Sync
- In typescript development
- Works in node.js (Not support web currently)
Why not in python but nodejs
I Don't know.
Normal Usage
zipDataInPng()
Hide a hello.zip
into deno.png
, and output the file named final.png
import path from "path";
import { zipDataInPng } from 'zip-data-in-png';
zipDataInPng (
path.join(__dirname, "deno.png"), // Original data
path.join(__dirname, "hello.zip"), // .zip file to hide
path.join(__dirname, "final.png") // Output file
)
pngAddHiddenContent()
Hide a hi.zip
into cat.png
, and return a Uint8Array
png Buffer for save in hidden.png
.
import fs from "fs";
import { pngAddHiddenContent } from 'zip-data-in-png';
const png_in = fs.readFileSync("cat.png", {flag:'r'});
const content_in = fs.readFileSync("hi.zip", {flag:'r'});
const result: Uint8Array = pngAddHiddenContent (
png_in, // Original data
content_in, // .zip file to hide
{ quiet: true } // Output file
)
fs.writeFileSync("hidden.png", result);
Sample
Hide a data.zip
into deno.png
, and output the file named result.png
import path from "path";
import { zipDataInPng } from 'zip-data-in-png';
zipDataInPng (
path.join(__dirname, "deno.png"), // Original data
path.join(__dirname, "data.zip"), // .zip file to hide
path.join(__dirname, "result.png") // Output file
)
Notices:
- The input file MUST be a
.png
file. - Hidden file MUST be a
.zip
file. - If you see
ERROR: Input files too big for cover image resolution.
, means the input.png
resolution is too high.
Params
export function zipDataInPng(
originalPngPath: string,
inputContentPath: string,
outputPath: string,
option?: zipDataInPngOptions
) : boolean
export function pngAddHiddenContent(
png_in: Buffer, // Png file
content_in: Buffer, // Zip file
option?: zipDataInPngOptions
): Uint8Array
interface zipDataInPngOptions {
quiet: boolean // Default: false, if true then will console.log all info
}
Advance usage
import path from "path";
import { zipDataInPng } from 'zip-data-in-png';
zipDataInPng (
path.join(__dirname, "deno.png"),
path.join(__dirname, "data.zip"),
path.join(__dirname, "result.png"),
{ quiet: false }
)
Logs
1.1
- Adding function
pngAddHiddenContent()
for advance usage.