Giter Club home page Giter Club logo

tweetable-polyglot-png's Introduction

Pack up to 3MB of data into a tweetable PNG polyglot file.

See it in action here: https://twitter.com/David3141593/status/1371974874856587268

image

Other image hosts I've verified this technique to work on:

Image hosts I've confirmed it doesn't work on:

  • Reddit (Perhaps it could be made to work by embedding data within the DEFLATE stream, rather than appending?)

How?

Twitter strips unnecessary data from PNG uploads, however, they do not strip trailing data from the DEFLATE stream inside the IDAT chunk, provided that the overall image file meets the requirements to avoid being re-encoded.

Why?

Dunno.

Cover image requirements

The cover image must compress well, such that the compressed filesize is less than (width * height) - size_of_embedded_file. If the cover image does not have a palette, then it must have at least 257 unique colours (otherwise twitter will optimise it to use a palette).

The resolution can be up to 4096x4096, however, be aware that twitter will serve a downscaled version by default, for images greater than 680x680 (depending on your display DPI, etc.).

The image should not have any unecessary metadata chunks. I used these export settings in GIMP:

image

Embedded file requirements

The total output file size must be less than 3MB (maybe 5MB?), otherwise twitter will convert the PNG to a JPEG.

If the embedded file is a .zip, then the offsets are automatically adjusted so that the overall file is still a valid zip. For any other file formats, you're on your own (many will work without any special handling, notably .pdf, .mp3).

tweetable-polyglot-png's People

Contributors

davidbuchanan314 avatar jb3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tweetable-polyglot-png's Issues

FileNotFoundError: [Errno 2] No such file or directory: 'cover.png'

I've been trying to use this tool but I can't figure out how to really use it.

I have a cover.png and a content.zip but I can't get an output. If I do
python pack.py cover.png content.bin output.png
I'll get the following:
FileNotFoundError: [Errno 2] No such file or directory: 'cover.png'
despite having a cover.png

iOS

com.github.stfalcon:swipeable-button:0.1.0'

Doesn't produce full final image

I took this image
toonoo
and embedded it with an mp3 of "Booty Wave" from the onion (lol they were the first mp3 and png I had in my downloads folder)
and had this as the final result
senanbooty
as you can see, this is not the same image as the original, although the audio part of it still works if I add the .mp3 extension at the end. (you'll have to play it in vlc as the default windows mp3 player doesn't work with it)

In addition, just to double check, I got this image
Ticox
and an mp3 of Toxic by Britney Spears with this as the result
Toxic

MP3 file won't play

I created image with embem mp3 file

Image size: 2765x4096px
Embedded file starts at offset 0x2a74c1

Issue is that after making png into mp3 it plays 10 sec of silence.

Inconsistent Imgur Link behavior

I'm not sure what exactly triggers it, but when opening the direct imgur URL from the readme https://i.imgur.com/kNhGrN3.png Imgur will often redirect do the gallery page for the image instead: https://imgur.com/kNhGrN3
image

The img displayed on this page is no longer the original png, but instead a webp:
image
https://i.imgur.com/kNhGrN3_d.webp?maxwidth=760&fidelity=grand which breaks the encryption.

When the redirect occurs it happens for both clicking the direct link or manually pasting the direct link into the address bar. However after it occurring several times in a row (which prompted me to creating this issue) it now does not happen, and I can open the direct link without issue
image

I've observed this inconsistent behavior previously with my own images, especially when attempting to open a direct link on mobile. I'm not sure if there is a consistent way to avoid this, so I'd potentially recommend not listing imgur as supported, as when it does this the image displayed to the user will not work.

I'm using Chrome Version 94.0.4606.71 for Windows 10

Doesn't work

I'm testing out this program with a couple test images.

Cover image:
moonwiki

Data:
moon2

Command:

python pack.py ~/Downloads/moonwiki.png ~/Downloads/moon2.jpg ~/Downloads/poly3.png

Output:

Image size: 2892x1696px
Warning: dropping non-essential or unknown chunk: pHYs
Embedded file starts at offset 0x13212f

Here is the output file itself:
poly3

It does not seem to be a usable zip file or anything.

I was wondering if you had any insight into what is going wrong here?

Not Working Anymore?

I used the tool to make a PNG, and it does work and open. But when uploaded and downloaded through Twitter, it doesn't work anymore. It seems like the image has been compressed to a couple kilobytes. Any ideas? I tried using the original image in the tweet that David posted, but even that didn't work.

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.