Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Custom Social Images for Building Pages #143

Open
vkoves opened this issue Dec 19, 2024 · 3 comments
Open

Create Custom Social Images for Building Pages #143

vkoves opened this issue Dec 19, 2024 · 3 comments
Assignees

Comments

@vkoves
Copy link
Owner

vkoves commented Dec 19, 2024

If we want to make Electrify Chicago easy to share, adding a helpful social preview image (maybe showing the building image, the energy mix, and some rankings) would be helpful. Here's how it looks right now:

image

For comparison, here's how GitHub's social images look when you share this repo:

image

I did something like this with imagemagick for chiwho.bike, where I created a template image and then added the interview photo on top of it, but adding text or graphs is likely to be more complex.

For Chicagoans Who Bike, the command looked like:

  # Resize the source image to 630px tall to match the social image, then add it onto our template
  # on the left hand side (-gravity West). We output to JPG (rather than WEBP) for higher
  # compatibility, since social media images can be ingested by back-end services
  convert ./imgs/cwb-social-template.png $prim_img_path -resize x630 -composite -quality 80 -gravity West ./imgs/interviews/$1/$1-social.jpg

Where $prim_img_path was the image I was using, and cwb-social-template.png was the underlying base image. This just combines two images, but ImageMagick also has tools to write text.

@vkoves
Copy link
Owner Author

vkoves commented Feb 5, 2025

Here's the social image file we worked on tonight, in this Figma:

Image

And here's the image without everything:

Image

@vkoves
Copy link
Owner Author

vkoves commented Feb 5, 2025

The Python package wand may also help, see: https://github.com/emcconville/wand

@vkoves
Copy link
Owner Author

vkoves commented Feb 8, 2025

@vaidehia something else I stumbled upon, that you could consider:

https://joyofcode.xyz/dynamic-social-share-images#javascript

Hypothetically we could do this via a page on the website and then export screenshots, which would let us do more complex stuff via CSS, and could let us import our existing graphs. Might be a good option if Image Magick has been pretty complex!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants