Twitter got a new design, and that broke our pictures - these geniuses made rectangle previews for everything, even for square pictures.

Fortunately there is a kinda workaround - to post GIFs instead of images, because GIFs don’t get rectangle previews. Retarded problems - retarded solutions.

What exactly got broken

Here’s how it was before the redesign:

Twitter, old design

And here’s how it looks now:

Twitter, new design

Thank you very fucking much, Twitter, that’s exactly what we wanted.

Just how the fuck did they come up with this idea? Have they seen any posts with images at all? Did they really think everybody would be okay with these crippled previews? Is everybody okay?

A workaround

Good news is that videos and GIFs are not affected, so those can still be square. And that’s what we’ll do - make GIFs from images.

In our case it is not so retarded, because we actually have 2 images: the main picture with the poster and general ratings and another picture with detailed ratings.

Here’s how you can join images into a GIF using FFmpeg:

ffmpeg -r 1/5 -i "concat:image-main.png|image-detailed.png" out.gif -y

Calling that from C# can look like this:

string pathToGIF = "/tmp/deutschland.gif",
       pathToImageMain = "/var/www/protvshows/images/deutschland-main.png",
       pathToImageDetailed = "/var/www/protvshows/images/deutschland-detailed.png";

var process = new Process()
{
    StartInfo = new ProcessStartInfo
    {
        FileName = "ffmpeg",
        Arguments = $"-r 1/5 -i \"concat:{pathToImageMain}|{pathToImageDetailed}\" {pathToGIF} -y",
        RedirectStandardOutput = true,
        RedirectStandardError = true,
        UseShellExecute = false,
        CreateNoWindow = true,
    }
};
process.Start();
process.WaitForExit();

// in case of FFmpeg you can't rely on process.StandardError.ReadToEnd()
// actually you can, but you don't want to
if (File.Exists(pathToGIF))
{
    // you can now upload the file to Twitter
}
// also don't forget to delete it just in case

It actually would be much better to upload videos instead of GIFs, but uploading a video to Twitter is a bit more complex than uploading a GIF (which still counts as an image, hence no changes in the code), and I didn’t have time to deal with it. Maybe later. that is how it is done.

Other notes

Along the way I discovered a different kind of issue.

According to Twitter documentation about response codes, this is the format of returning errors:

{
  "errors": [
    {
      "message": "Sorry, that page does not exist",
      "code": 34
    }
  ]
}

But here’s what I actually got in response to one of my requests when I tried to upload a video as an image:

{
  "request": "/1.1/media/upload.json",
  "error": "media type unrecognized."
}

Doesn’t really match the documented structure, does it? Also this dot at the end is just cute.

I wanted to report it, but Twitter’s forum doesn’t let you to register there without authorizing it to use your Twitter account, so it can go fuck itself.