-
Notifications
You must be signed in to change notification settings - Fork 246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@vercel/og Error: Unsupported Image Type #311
Comments
Hey @odiseo0 i faced this issue and was solved putting the image extension after url. Try switch export default function handler() {
return new ImageResponse(
(
<img
alt="Vercel"
height={200}
src="https://via.placeholder.com/302.png"
style={{ margin: '0 30px' }}
width={232}
/>
),
); |
Hi @itbruno, thanks for the response. I was looking to use I didn't know that placeholder.com accepted extensions, thanks for that too. |
Thanks for the help, I'll leave the issue open for a while in case someone have some sort of solution |
I'm seeing the error |
You can use this approach to temporarily solve this problem: import axios from 'axios'
import sharp from 'sharp';
const getImageBase64 = async (url: string) => {
return axios.get<ArrayBuffer>(url, {
responseType: 'arraybuffer',
}).then(async (res) => {
const buffer = await sharp(res.data).toFormat('png').toBuffer()
return {
url: `data:${'image/png'};base64,${buffer.toString('base64')}`,
};
})
} Then use const image = await getImageBase64('https://via.placeholder.com/302.png')
return new ImageResponse(<img src={image.url} />) |
@kodiyak This workaround isn't possible in edge environments because sharp relies on |
Hi, |
As it says in the title, the problem is related to @vercel/og and not to this repository as such, but I don't know any other place to ask.
I am using
ImageResponse
to generate the image as it says in the documentation, everything works fine, the problem starts when I try to use an image that is not either jpg/png. I want to usewebp
.You can follow the instructions of the official docs for @vercel/og
Code I used:
You'll get a blank page and in the terminal you should see:
My questions are, what are the supported image types? If there a way to make
ImageResponse
acceptwebp
? and have anyone else faced this issue, if you did, what were your solutions? ThanksThe text was updated successfully, but these errors were encountered: