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

GifError: Invalid block size #41

Open
DeanVanGreunen opened this issue Jul 26, 2022 · 0 comments
Open

GifError: Invalid block size #41

DeanVanGreunen opened this issue Jul 26, 2022 · 0 comments

Comments

@DeanVanGreunen
Copy link

Hi, occasionally I'm getting this error, i think it had to do with GifUtil

GifError: Invalid block size
at new GifReader (/var/www/gifier/node_modules/omggif/omggif.js:489:41)
at GifCodec.decodeGif (/var/www/gifier/node_modules/gifwrap/src/gifcodec.js:55:26)
at /var/www/gifier/node_modules/gifwrap/src/gifutil.js:222:24

here is my code blocks

getGifFrames

async function getGifFrames(file){
    return new Promise((resolve)=>{
        GifUtil.read(file).then(inputGif => {
            resolve(inputGif.frames);
        });         
    });
}

mergeThumbnail

async function mergeThumbnail(text, gifImage, outputImage, playIcon){
    return new Promise( async (resolve, reject)=>{
        const font = await Jimp.loadFont(Jimp.FONT_SANS_32_BLACK);
        const font2 = await Jimp.loadFont(Jimp.FONT_SANS_32_WHITE);
        const res = sizeOf(gifImage);
        const width = res.width, height = res.height;
        let frames = [];
        let gif_frames = [];
        try {
        gif_frames = await getGifFrames(gifImage);        
        } catch(e13){
            reject(false);
        }
        const sec_img = (await Jimp.read(playIcon)).resize(48, 48);  
        let w = (width / 2) - (sec_img.bitmap.width / 2);
        let h = (height / 2) - (sec_img.bitmap.height / 2);
        let x = 0;
        let y = height - 56;
        let maxWidth = 320;    
        
        gif_frames.forEach((frame) => {
            let image = new Jimp(frame.bitmap.width, frame.bitmap.height);
            image.bitmap = frame.bitmap;            
            image.blit(sec_img, 136, 156, 0, 0, 48, 48); 
            // do stuff here (shortned)
            GifUtil.quantizeDekker(image);
            
            frames.push(new GifFrame(new BitmapImage(image.bitmap)));
        });        

        GifUtil.write(outputImage, frames);
        resolve(outputImage);           
    });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant