jimp-dev / jimp

An image processing library written entirely in JavaScript for Node, with zero external or native dependencies.
http://jimp-dev.github.io/jimp/
MIT License
14.04k stars 760 forks source link

TypeError: Cannot read property 'interlace' of undefined #978

Closed moom0o closed 3 years ago

moom0o commented 3 years ago

Expected Behavior

Should upscale the image

Current Behavior

Fails with error

TypeError: Cannot read property 'interlace' of undefined
    at module.exports (/home/debian/MOO/moobot/9b9t/node_modules/@jimp/png/node_modules/pngjs/lib/parser-sync.js:79:16)
    at Object.exports.read [as image/png] (/home/debian/MOO/moobot/9b9t/node_modules/@jimp/png/node_modules/pngjs/lib/png-sync.js:10:10)
    at Jimp.parseBitmap (/home/debian/MOO/moobot/9b9t/node_modules/@jimp/core/dist/utils/image-bitmap.js:196:53)
    at Jimp.parseBitmap (/home/debian/MOO/moobot/9b9t/node_modules/@jimp/core/dist/index.js:431:32)
    at /home/debian/MOO/moobot/9b9t/node_modules/@jimp/core/dist/index.js:373:15
    at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:63:3) {
  methodName: 'constructor'
}

Failure Information (for bugs)

Steps to Reproduce

Use the example code map

            var Jimp = require('jimp');

            Jimp.read('map.png', (err, lenna) => {
                if (err) throw err;
                lenna
                    .resize(256, 256) // resize
                    .quality(70) // set JPEG quality
                    .write('upscaled.jpg'); // save
            });

Context

Failure Logs

TypeError: Cannot read property 'interlace' of undefined
    at module.exports (/home/debian/MOO/moobot/9b9t/node_modules/@jimp/png/node_modules/pngjs/lib/parser-sync.js:79:16)
    at Object.exports.read [as image/png] (/home/debian/MOO/moobot/9b9t/node_modules/@jimp/png/node_modules/pngjs/lib/png-sync.js:10:10)
    at Jimp.parseBitmap (/home/debian/MOO/moobot/9b9t/node_modules/@jimp/core/dist/utils/image-bitmap.js:196:53)
    at Jimp.parseBitmap (/home/debian/MOO/moobot/9b9t/node_modules/@jimp/core/dist/index.js:431:32)
    at /home/debian/MOO/moobot/9b9t/node_modules/@jimp/core/dist/index.js:373:15
    at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:63:3) {
  methodName: 'constructor'
}
moom0o commented 3 years ago

It was because I was reading the file while it was being written.