Twitter acquired Threader! Learn more

+ Your AuthorsArchive @Foone Hardware / software necromancer, collector of Weird Stuff, maker of Death Generators. (they/them) ko-fi: Oct. 23, 2021 5 min read

Doing a quick test because reportedly twitter has changed The Rules:

another test

keep on testing'


ok I need to do more tests to be sure, but it seems The Rules are now:
PNG images under 900x900 stay PNG

Other PNG images are converted to JPEG and the smaller of the two is posted

PREVIOUSLY there was also a rule that 8-bit PNGs stayed PNG.
That exception seems to have been removed.

This image here:

was originally a big 8-bit PNG but it turned into a JPEG on posting

This image was also a large (>900x900) PNG, but since it was bigger when converted to JPEG, it stayed a PNG

This image would have been smaller as a jpeg: (163kb vs 272kb), but since it's under 900x900, it stays a PNG:

so yeah. It seems the tl;dr right now for posting PNG images for maximum pixel art quality is:
To 100% guarantee PNG, it has to be under 900x900.
Otherwise you MAY get png, but only if your image stays smaller than the equivalent JPEG.

at some point I should build an automatic test suite for twitter.
like it's a series of images with different attributes and it tries posting them all and measures if they get turned into JPEGs or stay PNGs

I wonder if twitter has fixed the static GIF bug? let's find out


wow! They have!

ok yeah it turned into a JPEG which is sub-optimal, it really should become a GIF, but I imagine it's being run through the same "if smaller as PNG, stay PNG, else JPEG" check as before?

lemme find a GIF that will definitely be smaller as a PNG and confirm

converting this image results in a 4k JPEG and a 1K PNG
(it's also a 1K GIF)

yep, that's a JPEG alright.

OK so the single-frame-GIF bug has been fixed and they can be posted again, with the minor downside that they turn into JPEGs

ok so looking at the official document (which has been updated since the December 2018 date it says) it seems the actual situation is more complicated. I need to make more tests to confirm that this is accurate 

although, actually, no, the info that's been updated is all about JPEG and how JPEGs will be modified going forward, and WEBP support.

It's still listing the incorrect info about PNGs

like, according to that document, unless I'm completely misreading it, an 8-bit PNG should always stay an 8-bit PNG, even if it's bigger than 900x900 and even if it would be smaller if turned into a JPEG

which is not what I'm seeing happen today.

anyway while we're testing images, lemme try sharing a webp file, and according to this document it'll be supported but converted to a JPEG

Yep. That does seem to be what happened

this is all tested on web, btw.
There has just been a bunch of changes to image handling on mobile, so it's possible (if not likely) that mobile twitter is handling images completely differently

I wonder if, along with the GIF->JPEG conversion, they've enabled any other file formats?
Are they just throwing everything at gdlib/imagemagick/whatever?

testing a BMP

hah wow.
OK so you can post BMP files now, but you have to trick twitter!

See, it does two checks on what images you try to post:
1. in the browser
2. in the server

if you name your image whatever.gif, it will usually pass the browser check, and then the server will notice it's not a PNG or JPEG or GIF, and apparently it can convert BMP

and I now remember this isn't new:

I can't get it to try JPEG XL.
I think I'd need a browser that supports it, but I can't get Firefox to support it at all right now

it's possible the server supports some image formats that the browser half doesn't, but you'd need to use the API to try uploading them and "using the twitter API to explore the support for explicitly unsupported image types" is dangerously close to looking for security exploits

so I, personally, am not going to try it

I believe they still don't support APNG (AND NEITHER SHOULD THEY SUPPORT THAT ACURSED FORMAT) but maybe they treat them like animated GIFs now and turn them into mp4?

They keep them PNGs but they shear off the animation metadata, in order to make it a valid PNG again

hang on testing again, I may have made a mistake

ok nope.
I'd done some weirdness with imagemagick which meant I wasn't 100% sure that image counted as a 256-color image, even if it technically only had 256 colors.
I'm certain that one does, and it still gets converted to JPEG

ahh-ha! I have a theory. Hang on...


or should I say... PNGO!

ok so let's look at the Pile Of Lies known as the "Upcoming changes to PNG image support" document: 

I thought this part was completely a lie now. That's not actually true.

So, it turns out THIS PART is now important when it comes to PNGs.
You might not think this, because it's all about JPEGs, but it apparently is.

and the key part that's relevant is "4096x4096 or smaller"

The stated PNG rules are being ignored if the image is bigger than 4096x4096!

So the actual rules are:
1. PNGs smaller than 900x900 stay PNG
2. 8-bit paletted PNGs smaller than 4096x4096 stay PNG
3. Other images are tested against JPEGs and the smaller filesize is used

I think.
It's possible that if your PNG image is bigger than 4096x4096, even if it's 8-bit AND it is smaller than a JPEG, it always gets converted to JPEG. I'm too lazy to test right now

it's possible the actual rules are even weirder. I suspect twitter made some mistakes on implementing this and they'll fix it... sometime. So I don't think even they understand the actual rules right now

anyway the good news is that these changes will not stop me from posting the entirety of Doom1 shareware

yeah. it didn't stop me

You can follow @Foone.


Tip: mention @threader on a Twitter thread with the keyword “compile” to get a link to it.

Follow Threader