Upcoming changes to PNG image support

Historically, Twitter has supported JPEG and PNG format images. Over the years, we’ve made improvements to our image pipeline moving towards faster load times while improving quality within reasonable constraints. Starting February 11th, we are going to extend this effort to better support users globally with how we handle uploaded images, with a focus on how we handle PNG images.

What are the changes being made?
The way Twitter handled PNG uploads in the past was not always consistent and could lead to large PNG images being used when a JPEG would have been preferable for image load latency and user data costs. The changes we’re making will provide consistent behavior that can be depended on by those uploading images to Twitter to reach a global audience.

What image categories are going to be impacted?
These changes will be applied to all images uploaded to Twitter from February 11th and forward, regardless of the category the image is for.

What is the behavior going to be for uploaded JPEG images?
Uploaded JPEG images will remain in JPEG format, transcoded to 85% JFIF quality if the uploaded image has a higher quality. There’s really no change.

What is the behavior going to be for uploaded WebP images?
Uploaded WebP images will all be converted to JPEG at 85% JFIF quality. The occasional conversion to PNG will no longer occur. WebP is will remain solely as a supported upload format, and Twitter will continue to not serve images as WebP.

What is the behavior going to be for uploaded PNG images?
PNG images are where there will be the most change and we want to detail the behavior clearly. There are actually numerous kinds of PNG formats and each needs to be considered. The change in behavior is going to move Twitter to converting more PNG images to be JPEG while offering a way to keep some PNG images as PNG as long as they meet criteria that has been set to achieve the image load performance needed at a global scale.

The simple breakdown is that lower color depth PNG images are encoded small enough to have better sizes than a JPEG counterpart, and we want to keep these PNG images. For high color depth PNG images, they are most often very large compared to a JPEG and delivering those images efficiently at a global scale is not feasible. For those high color PNG images, we will take extra steps to consider if we keep the PNG or, most likely, convert it to a JPEG.

Chart of breakdown:

PNG RGB Color w/ Alpha RGB Color Grayscale w/ Alpha Grayscale Palette Based
1 bit n/a n/a n/a Leave PNG Leave PNG
2 bit n/a n/a n/a Leave PNG Leave PNG
4 bit n/a n/a n/a Leave PNG Leave PNG
8 bit Test Test Test Test Leave PNG
16 bit Test Test Test Test n/a


Which of those PNG formats are the most common?
The most common PNGs are PNG-24 and PNG-32. PNG-24 has RGB Color with 8 bit depth color, that is to say it uses 8 bits per channel with 3 color channels (RGB) for a total of 24 bits per pixel. PNG-32 has RGB Color w/ Alpha with 8 bit depth color, that is to say it uses 8 bits per channel with 3 color channels (RGB) plus an alpha channel for a total of 32 bits per pixel. Both PNG-24 and PNG-32 will be tested to consider if they will remain PNG or if they will be converted to JPEG, which is more likely.

A not so uncommon PNG format is PNG-8. PNG-8 is a Palette Based image with 8 bit depth color, that is to say it uses a palette to look up all of its colors and can support full RGB and Alpha color but has a maximum of 8 bits worth of colors, a.k.a. 256 colors in the palette. PNG-8 images will always stay as PNG-8 and won’t be converted.

What happens if I upload a PNG image that needs to be tested?
The test we apply to a high color depth PNG is that we will look at its file size and compare that to what it’s converted JPEG file size would be. If the PNG is sufficiently small enough based on a Twitter internal metric compared to the JPEG version, we will leave the PNG alone and use that. In the more common case, the PNG will be larger than our metric and will be converted to JPEG.

This testing is offered as a way for image creators to have the ability to construct and compress their PNG before upload to have a better chance at remaining a lossless quality PNG. This is going to be a rare case, but images dominated with solid colors have this potential so Twitter is taking the steps to support these PNG images.

What’s the advantage of supporting PNG-8 image?
The advantage of Twitter supporting PNG-8 images (also called 8-bit PNGs), is that images with a reduced color palette of 256 colors will now have a way to upload lossless quality images to Twitter that will be preserved unmodified. They are small enough to be as performant as JPEG or better, so there is less compromise with image artifacts from JPEG compression or large file sizes that PNG-24 and PNG-32 images can reach. PNG-8 also support alpha, so if transparency is desired, using part of the color palette to have transparent and semi-transparent pixels is an option.

What happens to images with transparency when converted to JPEG?
Images converted to JPEG that had transparency will have a white background applied.

If you have any questions, feel free to raise technical problems or concerns by replying to this post.
Thank you, and we look forward to seeing an even greater global reach for images on Twitter!

Update: 12/26/2018 It was unwitting to call for feedback when Announcements are automatically locked. I’m sorry for that poor execution. A forum thread has been opened for feedback here:

Feedback for “Upcoming changes to PNG image support”