-
Notifications
You must be signed in to change notification settings - Fork 17
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
Error: Frame 0 uses more than 256 color indexes #34
Comments
I'm using the above code to fix the colors, the error itself comes from this code async function getFileBitmap(file){
return new Promise((resolve)=>{
Jimp.read(file)
.then(image => {
resolve(image.bitmap.data);
})
});
}
async function getGifFrames(file){
return new Promise((resolve)=>{
GifUtil.read(file).then(inputGif => {
resolve(inputGif.frames);
});
});
}
async function resizeImage(file, w, h){
return new Promise((resolve)=>{
Jimp.read(file, function (err, test) {
test.resize(w, h)
.quality(50)
.write(file);
resolve();
});
});
} here is the main function async function mergeThumbnail(baseImage, gifImage, outputImage){
return new Promise( async (resolve, reject)=>{
const res = sizeOf(gifImage);
const width = res.width, height = res.height;
await resizeImage(baseImage, width, height);
await fixColors(baseImage);
const frames = [];
let frame = new GifFrame(width, height, { delayCentisecs: 200 });
frame.bitmap.data = await getFileBitmap(baseImage);
frames.push(frame);
let gif_frames = await getGifFrames(gifImage);
gif_frames.forEach(frame => {
frames.push(frame);
});
GifUtil.write(outputImage, frames);
resolve();
});
} |
Hi @Giv0 Any ideas? |
GifUtil.quantizeDekker(ouputImage,256); |
Solution above does work and if any of you want to see it in another example here is mine: import { BitmapImage, GifCodec, GifFrame, GifUtil } from 'gifwrap';
import Jimp from 'jimp';
import { addLogoToImage } from './index';
const codec = new GifCodec();
export const addLogoToGif = async (buffer: Buffer): Promise<Buffer> => {
const gif = await codec.decodeGif(buffer);
const p = gif.frames.map(async (frame) => {
const jimpImage = GifUtil.copyAsJimp(Jimp, frame);
const buffer = await jimpImage.getBufferAsync(jimpImage.getMIME());
const buffWithLogo = await addLogoToImage(buffer);
const frameWithLogo = await Jimp.read(buffWithLogo);
const bitmap = new BitmapImage(frameWithLogo.bitmap);
GifUtil.quantizeDekker(bitmap, 256);
return new GifFrame(bitmap);
});
const gifWithLogo = await Promise.all(p);
const buf = await codec.encodeGif(gifWithLogo, { loops: 0 });
return buf.buffer;
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Error: Frame 0 uses more than 256 color indexes
The text was updated successfully, but these errors were encountered: