Skip to content

Instantly share code, notes, and snippets.

@PetterRuud
Created April 19, 2021 20:33
Show Gist options
  • Save PetterRuud/abc8996bd1db13efc2424e11d99a0024 to your computer and use it in GitHub Desktop.
Save PetterRuud/abc8996bd1db13efc2424e11d99a0024 to your computer and use it in GitHub Desktop.
GROQ query to pull data for image palette information
*[_id =="documentWithImage"]{
...,
image{
..., // Get all information
"palette": asset->metadata.palette // Pull palette from metadata on the asset
}
}
{
"_id": "documentWithImage",
"title": "A document with an image",
// ... other data
"image": {
"_key": "5f34eed722c8",
"_type": "image",
"asset": {
"_ref": "image-df9f14aaebefb17704af30c01d6fcd7eca624afe-3000x4542-jpg",
"_type": "reference"
},
"caption": "Plants",
"palette": {
"_type": "sanity.imagePalette",
"darkMuted": {
"_type": "sanity.imagePaletteSwatch",
"background": "#294a41",
"foreground": "#fff",
"population": 7.7,
"title": "#fff"
},
"darkVibrant": {
"_type": "sanity.imagePaletteSwatch",
"background": "#094836",
"foreground": "#fff",
"population": 0.32,
"title": "#fff"
},
"dominant": {
"_type": "sanity.imagePaletteSwatch",
"background": "#294a41",
"foreground": "#fff",
"population": 7.7,
"title": "#fff"
},
"lightMuted": {
"_type": "sanity.imagePaletteSwatch",
"background": "#94b7a8",
"foreground": "#000",
"population": 3.2,
"title": "#fff"
},
"lightVibrant": {
"_type": "sanity.imagePaletteSwatch",
"background": "#9adfd2",
"foreground": "#000",
"population": 0,
"title": "#000"
},
"muted": {
"_type": "sanity.imagePaletteSwatch",
"background": "#649c7e",
"foreground": "#fff",
"population": 0.36,
"title": "#fff"
},
"vibrant": {
"_type": "sanity.imagePaletteSwatch",
"background": "#287e6e",
"foreground": "#fff",
"population": 0.06,
"title": "#fff"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment