Giter Club home page Giter Club logo

png-pdvzip's Introduction

pdvzip

PNG Data Vehicle for Twitter, ZIP Edition (PDVZIP).

Embed a ZIP file of up to ≈5MB within a tweetable and 'executable' PNG polyglot image.

Based on a similar idea from the original Python program 'tweetable-polyglot-png' created by David Buchanan, pdvzip uses different methods for storing and accessing arbitrary data within a PNG image file.

Compile and run the program under Windows or Linux.

Usage

$ g++ pdvzip.cpp -o pdvzip
$
$ ./pdvzip

Usage:  pdvzip  <png_image>  <zip_file>
        pdvzip  --info

Once the ZIP file has been embedded within a PNG image, it's ready to be shared (tweeted) or 'executed' whenever you want to open/play the media file.

You can also upload and share your PNG image to *some popular image hosting sites, such as Flickr, ImgBB, Imgur, ImgPile, ImageShack, PostImage, etc. *Not all image hosting sites are compatible, e.g. ImgBox, Reddit.

Mobile Issue: Sometimes when saving images from Twitter to a mobile, the file gets saved with a '.jpg' extension. Please note, the file has not been converted to a JPG. Lazy Twitter has just renamed the extension, so it is still the original PNG image with its embedded content.

Accessing Arbitrary Data

Linux
Make sure image file has executable permissions.

$ chmod +x pdv_your_image_file.png
$
$ ./pdv_your_image_file.png 

Windows
First, rename the '.png' file extension to '.cmd'.

G:\demo> ren pdv_your_image_file.png pdv_your_image_file.cmd
G:\demo>
G:\demo> .\pdv_your_image_file.cmd

Opening the cmd file from the desktop, on its first run, Windows may display a security warning. Clear this by clicking 'More info' then select 'Run anyway'.

For some common video & audio files, Linux requires the 'vlc (VideoLAN)' application, Windows uses the set default media player.
PDF '.pdf', Linux requires the 'evince' application, Windows uses the set default PDF viewer.
Python '.py', Linux & Windows use the 'python3' command to run these programs.
PowerShell '.ps1', Linux uses the 'pwsh' command (if PowerShell installed), Windows uses 'powershell' to run these scripts.

For any other media type/file extension, Linux & Windows will rely on the operating system's set default application.

To just get access to the file(s) within the ZIP archive, rename the '.png' file extension to '.zip'. Treat the ZIP archive as read-only, do not add or remove files from the PNG-ZIP polyglot file.

Image Examples

  1. Twitter. Tweet contains four images. Embedded with (TL) Python, (TR) MP3, (BL) PDF, (BR) MP4
  2. Imgur. This image contains an embedded zip/PDF document
  3. PostImages. This image contains an embedded zip/JPG image (Always select: "Download original image")

Video Examples (YouTube)

  1. MP4 Video (Linux & Windows Demo)
  2. Python Program (Linux & Windows Demo)
  3. PDF Document (Windows & Linux Demo)

PNG Image Requirements for Arbitrary Data Preservation

Bit depth 8-bit or lower (4,2,1) Indexed colour (PNG colour type value 3).

Image's multiplied dimensions value must be between 5,242,880 and 5,500,000. Suggested Width x Height Dimensions: 2900 x 1808 = 5,243,200. Example Two: 2290 x 2290 = 5,244,100, etc.

Valid PNG chunk types that Twitter will preserve arbitrary data: bKGD, cHRM, gAMA, hIST, iCCP, pHYs, sBIT, sPLT, sRGB, tRNS. We can also use an IDAT chunk type after the last image data IDAT chunk. This program uses hIST & IDAT chunk types and removes the others.

  • Dimensions provide the storage capacity for our PNG image + arbitrary data. For example, 2900 x 1808 is 5,243,200, slightly over 5MB. This covers us for up to Twitter's 5MB size limit, same with other similar range dimension combinations (e.g. 2290 x 2290). Its pointless going too far over 5,242,880 for W x H dimensions, considering the 5MB PNG size limit.

  • Bit depth setting of 8-bit or lower (4,2,1) Indexed colour (PNG colour type value 3), 'enables' preservation of arbitrary data in the above 11 PNG chunk types.

These settings are mostly the result of trial and error tinkering with PNG image files. As we can't see how the Twitter code is handling image configurations, we are unable to say why this works the way it does.

ZIP File Size & Other Important Information

To work out the maximum ZIP file size, start with Twitter's size limit of 5MB (5,242,880 bytes), minus your PNG image size, minus 400 bytes (internal script size).

Example: 5,242,880 - (307,200 + 400) = 4,935,280 bytes available for your ZIP file.

The less detailed your image, the more space available for the ZIP.

  • Make sure your ZIP file is a standard ZIP archive, compatible with Linux unzip & Windows Explorer.
  • Always use file extensions for your media file within the ZIP archive: my_doc.pdf, my_video.mp4, my_program.py, etc.
  • Paint.net application is recommended for easily creating compatible PNG image files.

Video Example

Paint.net: Configure Correct PNG Image Settings for PDVZIP

png-pdvzip's People

Contributors

cleasbycode avatar

Stargazers

 avatar

Watchers

 avatar

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.