Created
February 15, 2019 20:58
-
-
Save asilvas/773b902b2d175d452c6472a4ed128762 to your computer and use it in GitHub Desktop.
Invalid SOS (sharp/vips/jpeg)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
})(); |
solution in lovell/sharp#1578
thanks Julian, missed this!
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.
Out of country for another week but will provide when I get back
Thank you @asilvas !
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@asilvas
I also face same error. Were you able to solve the issue?
Any help is highly appreciated.
Thank you!