Manipulating Images for Social Media during Build

I’d like to create my first middleman extension for the community because I have a feeling many of us could use it. Every blog post I create in Middleman has a primary image to accompany the post. As you may know Facebook, Twitter’s Cards, and Pinterest all have different image dimension recommendations when sharing content to their platform. How does this sound for a design?

Frontmatter of a post specifies an image to use for social sharing
On build phase
For each social media service (facebook, twitter & pinterest at first some sort of config file for the gem to add additional services or change the dimensions for each service)
The specified image is checked for proportions of the desired service, command line log and stop if bad proportions
A copy of the desired image is made and reduced to the dimensions of the desired service

Things to figure out: for images that are wrong dimensions (i.e.: would lead to weird images when straight reduced) for the desired service figure offer default places to generate/crop from top left (0,0), top right (X, 0), bottom left (0,Y), bottom right (X,Y) and center (X/2,Y/2). How to return the image file path and meta tags for sharing.

Maybe you can use the Middleman extension for Open Graph (ie Facebook) for some of the metatags.

1 Like

Nice! Ideally I’d like to generate the image for the OGP image meta tag. I’ll look into that as I get farther along.

hello @scottelundgren

Maybe you can have a look for this gem wich generate favicon images