Skip to content

Commit

Permalink
feat(decoder): add FFDC marker support (jpeg-js#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chupsy authored Aug 24, 2020
1 parent 422ae38 commit 05bb97a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/decoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,11 @@ var JpegImage = (function jpegImage() {
resetInterval = readUint16();
break;

case 0xFFDC: // Number of Lines marker
readUint16() // skip data length
readUint16() // Ignore this data since it represents the image height
break;

case 0xFFDA: // SOS (Start of Scan)
var scanLength = readUint16();
var selectorsCount = data[offset++];
Expand Down
Binary file added test/fixtures/marker-ffdc.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,14 @@ it('should be able to encode/decode image with exif data', function () {
expect(loopImageData.exifBuffer).toEqual(imageData.exifBuffer);
});

it('should be to decode image with ffdc marker', function () {
var jpegData = fixture('marker-ffdc.jpg');
var imageData = jpeg.decode(new Uint8Array(jpegData));
expect(imageData.height).toEqual(200);
expect(imageData.width).toEqual(200);
});


it('should be able to decode large images within memory limits', () => {
var jpegData = fixture('black-6000x6000.jpg');
var rawImageData = jpeg.decode(jpegData);
Expand Down

0 comments on commit 05bb97a

Please sign in to comment.