How to programatically create image? #458
-
I need to programmatically create multiple images on build. I'm missing a sample in the documentation how to do this. In my case, For example, I have // favicon.ts
export const url = '/favicon.ico'
export default () => '' How to use ImageMagick programmatically (or whatever) to manipulate |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
The short answer: you can use this experimental plugin that not only generates all favicons but also generate the html tags to import them. If you want to use the imagick plugin, you can do something like this in your _config (I didn't test it): // Load the imagick plugin
site.use(imagick());
// Assign the `imagick` variable to the original image with all transformations
const transforms = [
{
size: [16, 16],
format: "ico",
}, {
size: [32, 32],
format: "png",
sufix: "-x32",
},
];
site.data("imagick", transforms, "/images/original-picture.png"); |
Beta Was this translation helpful? Give feedback.
The short answer: you can use this experimental plugin that not only generates all favicons but also generate the html tags to import them.
If you want to use the imagick plugin, you can do something like this in your _config (I didn't test it):