FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
tylergaw
tylergawsocialImage
Public
Like
2
socialImage
Home
Code
2
README.md
H
main.tsx
Branches
1
Pull requests
Remixes
1
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
8/11/2023
Viewing readonly version of main branch: v37
View latest version
README.md

Simple image generator

A bit of a toy image creator that can be used anywhere images can be, but is intended for social share images in og:image or twitter:image meta tags.

Usage examples

In a live web page

  • Live example https://tylergaw-socialimageusage.web.val.run/
  • Live example Val https://www.val.town/v/tylergaw.socialImageUsage

Code examples

Default

This will set the og:image of a web page to a png image of an orange 1200x600 pixel rectangle

<meta property="og:image" content="https://tylergaw-socialimage.web.val.run/">

Works the same way as an embedded image

<img src="https://tylergaw-socialimage.web.val.run/">

Customize with query parameters

General note, some clients are more permissive with unencoded query params than others. It's best to encodeURIComponent for all params.

Available params:

  • bg: Sets the background color. Default orange. See Color format examples below for details
  • color: Sets the background color. Default black. See Color format examples below for details
  • w: Sets the width of the image. Default 1200
  • h: Sets the height of the image. Default 600
  • text: Sets the text displayed. Default Wellow horld
<meta property="og:image" content="https://tylergaw-socialimage.web.val.run/?bg=pink&w=1000&h=400">

Color format examples

bg and color parameters can any valid color that works with canvas fillStyle in hex, rgb(a), hsl(a), rrggbbaa, etc format.

Note # must be encoded.

  • Hex ?bg=%235f0ac7
  • rgb(a) ?bg=rgba(100,200,85,0.5)
  • rrggbbaa ?bg=%23ff0095d1
  • hsl(a) ?bg=hsla(100,100%25,50%25,0.5)
Go to top
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Product
FeaturesPricing
Developers
DocsStatusAPI ExamplesNPM Package Examples
Explore
ShowcaseTemplatesNewest ValsTrending ValsNewsletter
Company
AboutBlogCareersBrandhi@val.town
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.