Extract brand colors from any website’s logo and preview image
Extract brand colors from a website without downloading a single image: the Metadata API returns the dominant palette of the page’s logo and preview image, with a background color and readable text colors already picked. Link cards, bookmark managers, CRMs and directory listings use it to tint each entry to the brand it points at.
Picking brand colors by hand does not scale past a few domains
Cards, embeds and link lists look generic in one shade of gray. Tinting each one to the linked brand needs a color you do not have, for thousands of domains you have never seen.
Doing it yourself means finding the logo and the og:image, downloading both, running a color quantizer and then checking contrast, because the most dominant color of an image is often unusable behind text. A hand-curated table of brand colors goes stale at the first rebrand.
With palette enabled, every image field in the metadata gains a palette array ordered from most to least dominant, plus background_color, color and alternative_color chosen for contrast. The colors arrive in the same response as the normalized metadata, so the card and its theme come from one request.
How to get a color palette from a logo or og:image
palette is a boolean and defaults to false. The computed colors arrive on the image and logo fields as hexadecimal strings, ready to drop into your CSS. The extending results guide lists the other enrichments that ride on the same request.
import createClient from 'microlink.io'
const microlink = createClient({
apiKey: process.env.MICROLINK_API_KEY
})
const { image, logo } = await microlink.metadata('https://example.com', {
palette: true
})
console.log(image.palette, image.background_color, image.color)Each image field now carries palette, an array of hex colors from most to least dominant, next to background_color, color and alternative_color.
import createClient from 'microlink.io'
const microlink = createClient({
apiKey: process.env.MICROLINK_API_KEY
})
const { title, logo } = await microlink.metadata('https://example.com', {
palette: true,
meta: { title: true, logo: true }
})
const card = {
backgroundColor: logo.background_color,
color: logo.color,
accent: logo.alternative_color
}Restricting meta to title and logo skips the detection you do not render. The logo palette is often the truest brand color, because preview images tend to be photographs.
curl 'https://api.microlink.io/?url=https%3A%2F%2Fexample.com&palette=true&meta.image=true&meta.logo=true'palette=true adds the color fields to every image field in the JSON. The request runs on the free endpoint, with no API key.
- palette Boolean, default false. Adds palette, background_color, color and alternative_color to every detected image field.
- meta Keep only image and logo when colors are all you need.
- data Extract a different image with a rule of type image and it gets a palette too.
- ttl Brand colors change rarely; cache them for up to 31 days. Pro plans.
background_color is the palette color with the best WCAG contrast ratio for use as a background, color is the best color to lay over it, and alternative_color is the second best. When only two colors can be parsed, alternative_color equals color.
Why compute dominant colors in the metadata API
The image is already fetched to measure its dimensions and size. Extracting its colors in the same pass saves you a download, a quantizer and a contrast library.
Use the raw palette array when you want to pick your own accent from the most dominant colors.
For a different image, add a custom data rule with type image and it carries the same color fields.
When not to: a monochrome logo or a photographic hero image produces a palette that is not the brand color. Fall back to your own accent when the pair looks off.
FAQ
Which fields does palette add to the metadata response?
How do I extract brand colors from a website without downloading its images?
Does palette work with a custom image extracted next to the metadata?
Are the colors from the metadata palette accessible?
Does palette slow down a metadata request?
Solve the next problem with the same API
Custom fields alongside metadata
Only the fields you need
Fix missing or wrong og:image
Link previews at scale
Dynamic Open Graph images
Screenshots with a browser frame
Ready to theme with brand colors?
Palettes and accessible pairs from the logo and image of any site. Start on the free tier and tint your first preview card today.