GithubHelp home page GithubHelp logo

thatguysam / daneden-og-image-generator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from daneden/daneden-og-image-generator

0.0 2.0 0.0 88 KB

An open graph image generator for my website, daneden.me

Home Page: https://daneden-og-image-generator.now.sh

TypeScript 76.42% HTML 23.58%

daneden-og-image-generator's Introduction

daneden.me OpenGraph Image Generator

This repo provides a serverless function, deployed on Zeit Now, which generates a 1200x1200px image for OpenGraph cards with a provided title.

It's used on my website, daneden.me, to automatically generate images to be attached to social media shares of my blog posts.

How it works

  1. A request is made to the API with a title query parameter. This string will be what gets rendered in the resulting image.
  2. The API generates an HTML string;
  3. The HTML string is passed to a Puppeteer instance running Chrome;
  4. Puppeteer is instructed to take a screenshot of the resulting page;
  5. This screenshot is returned as the response for the HTTP request;
  6. The response is cached for a long time via Now to prevent unnecessary (and expensive) image regeneration.

An important step I had to take to make this work was grabbing custom fonts as base64 strings, since it was hard to get Puppeteer to wait until fonts were loaded over HTTP.

daneden-og-image-generator's People

Contributors

daneden avatar thatguysam avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.