-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Feat: Allow generating base64 image string #4
Comments
Hmmm, I've never really considered this, probably because:
|
I am not sure those plugins will generate a blurred version of image.
If you can explain bit more on how to achieve I would like to send a PR |
We will get a buffer here, if I am not wrong const imageData = await blurhash.decode(hash, width, height, punch); I am not sure if we just encode and add the |
uhh, the rollup plugin of blurhash-as already generates the blurhash placeholder as an image (jpeg/png), it also has other info. You do know this, right? All of the demos are using that plugin. There's no PR necessary. For image processing using Here's an example: async function decode(request: Decode): Promise<sharp.Sharp> {
const aspectRatio = getAspectRatio(request.query);
const correctRatio = getNearestAspectRatio(aspectRatio);
const decodedBytes = await blurhash.decode(
request.query.hash,
correctRatio.width * SCALE,
correctRatio.height * SCALE,
);
return sharp(Buffer.from(decodedBytes), {
raw: {
width: correctRatio.width * SCALE,
height: correctRatio.height * SCALE,
channels: 4,
},
});
}
|
Oh I see. The rolup plugin should work with So if I am importing any local images with But in the docs it says it only supports |
I do see webp support though
|
I just can't get the plugin to work I keep getting
Config import { defineConfig } from "astro/config";
import tailwind from "@astrojs/tailwind";
import sitemap from "@astrojs/sitemap";
import preact from "@astrojs/preact";
import * as blurhash from "rollup-plugin-blurhash-as";
import image from "@astrojs/image";
// https://astro.build/config
export default defineConfig({
site: "https://introvert-test.com",
integrations: [tailwind(), sitemap(), preact(), image()],
vite: {
plugins: [
{
...blurhash(),
enforce: "pre",
},
],
},
}); Already tried the cjs version |
the format refers to the blurhash output, not the actual source file. For source images you can use either webp, png or jpeg. For using in an mjs file, I'll probably release fix. If you wanted to I might make the image processing as an open-source library. |
It would be great to have the plugin fixed for mjs files as well. And yes I would love to see the processing library as well. |
@lxsmnsyc any updates on this? |
Since I have been caught in more important work, I haven't had a time to work on this yet, but I can probably release the update this week. |
sure no problem even if I get this lib as API it would be great |
It would be great to have the ability to generate
base64
string which can be used in the image src directly.Eg
data:image/webp;base64,UklGRlIAAABXRUJQVlA4IEYAAACwAQCdASoEAAQAAUAmJQBOgCHfFPUAAP76o/ZQ5cVKv//aDeITqchzAx/i1Kcg6X9b/orzvs6JRg6h/yOfhkNTG+tTwAAA
The text was updated successfully, but these errors were encountered: