Skip to content

Instantly share code, notes, and snippets.

@asilvas
Created February 15, 2019 20:58
Show Gist options
  • Save asilvas/773b902b2d175d452c6472a4ed128762 to your computer and use it in GitHub Desktop.
Save asilvas/773b902b2d175d452c6472a4ed128762 to your computer and use it in GitHub Desktop.
Invalid SOS (sharp/vips/jpeg)
const sharp = require('sharp');
const http = require('http');
const IMAGE_URL = 'http://blobby.wsimg.com/go/0296993c-cade-4ae8-8a65-b3172f22a3a0/6e14af04-904c-4654-936e-2bd7e6e08dd8.jpg';
function getImage() {
return new Promise((resolve, reject) => {
http.get(IMAGE_URL, res => {
if (res.statusCode !== 200) return void reject(new Error(`Invalid response: ${res.statusCode}`));
const chunks = [];
res.on('data', chunk => chunks.push(chunk));
res.on('end', () => {
resolve(Buffer.concat(chunks));
});
}).on('error', reject);
});
}
(async () => {
const imageData = await getImage();
const image = sharp(imageData);
// the blow options won't matter, including output format.. anything will result in:
// Error: VipsJpeg: Invalid SOS parameters for sequential JPEG
// VipsJpeg: out of order read at line 0
const saveData = await image
.withMetadata()
.resize(640, 480)
.toFormat('jpeg')
.toBuffer();
})();
@naveenchandru1
Copy link

@asilvas
I also face same error. Were you able to solve the issue?
Any help is highly appreciated.
Thank you!

@juliangruber
Copy link

solution in lovell/sharp#1578

@asilvas
Copy link
Author

asilvas commented May 3, 2021

thanks Julian, missed this!

@blueskymonster
Copy link

Do you happen to have the corrupted test photo on hand still? I'm starting to see this error in my logs and would love to have a test image to write a unit test against.

@asilvas
Copy link
Author

asilvas commented Jul 26, 2022

Out of country for another week but will provide when I get back

@asilvas
Copy link
Author

asilvas commented Jul 31, 2022

@blueskymonster
Copy link

Thank you @asilvas !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment