I decided to use Imagor to optimise and transform the images into a stream. I am very happy with the results!
It is written in Go and is easy to run in Docker.
https://github.com/cshum/imagor
#selfhost
Woohoo, #phpub2twtxt - my php interface for publishing to my selfhosted twtxt.txt is now online at GitHub