Skip to content
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

Is embedded base64 images within SVG supported ? #3557

Closed
kenryu42 opened this issue Feb 11, 2023 · 2 comments
Closed

Is embedded base64 images within SVG supported ? #3557

kenryu42 opened this issue Feb 11, 2023 · 2 comments
Labels

Comments

@kenryu42
Copy link

What are you trying to achieve?

I am trying to convert a base64 SVG image as below to PNG format. But what I get is a blank image.

<svg width="100%" height="100%" viewBox="0 0 1200 1200" version="1.2" xmlns="http://www.w3.org/2000/svg">
    <image width="1200" height="1200" href="data:image/svg+xml;base64, ...">
    </image>
</svg>

When you searched for similar issues, what did you find that might be related?

According to @lovell #2157 's comment, this feature should be supported.

Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this question

const imageUrl =
        'https://nft-cdn.alchemy.com/eth-mainnet/ed3a191616815fe03d4bb216f0adb0f6';
const buffer = (await axios({ url: imageUrl, responseType: 'arraybuffer' }))
        .data;
const image = await sharp(buffer).png().toFile('test.png');

Please provide sample image(s) that help explain this question

https://nft-cdn.alchemy.com/eth-mainnet/ed3a191616815fe03d4bb216f0adb0f6

@lovell
Copy link
Owner

lovell commented Feb 11, 2023

Embedded base64-encoded SVG within SVG is unsupported using the prebuilt binaries. You'll need to compile your own libvips and dependencies from source to achieve this.

lovell/sharp-libvips#9

As I said in #2157 (comment), embedded base64-encoded PNG and JPEG images within SVG are supported.

@kenryu42
Copy link
Author

Ah! Got it. Thank you for the reply. 🫡

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants