Tweetable-polyglot-png

From Just Solve the File Format Problem
Revision as of 05:15, 3 September 2023 by Parchivist (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
File Format
Name Tweetable-polyglot-png
Ontology
Released 2021

tweetable-polyglot-png by David Buchanan is an open source Python script to pack up to 3MB of data into a tweetable PNG polyglot file.

Hosts where this works:

  • Twitter/X
  • Imgur
  • Github repo thumbnail/header image
  • Discord

Hosts where it doesn't work:

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

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.

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 unnecessary metadata chunks.

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).


Links

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox