-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Closed
Labels
good first issueIssue that doesn't require previous experience with GatsbyIssue that doesn't require previous experience with Gatsbystale?Issue that may be closed soon due to the original author not responding any more.Issue that may be closed soon due to the original author not responding any more.type: bugAn issue or pull request relating to a bug in GatsbyAn issue or pull request relating to a bug in Gatsby
Description
A follow up to #28614
Here are a few other places where sharp reads/writes images that don't seem to have try/catch setup around them.
| const pipeline = sharp(file.absolutePath) |
gatsby/packages/gatsby-plugin-sharp/src/duotone.js
Lines 103 to 123 in b81e6bd
| const duotoneWithTransparency = await duotoneImage | |
| .joinChannel(percentTransparency, { | |
| raw: { width: info.width, height: info.height, channels: 1 }, | |
| }) | |
| .raw() | |
| .toBuffer() | |
| return await originalImage | |
| .composite([ | |
| { | |
| input: duotoneWithTransparency, | |
| blend: `over`, | |
| raw: { width: info.width, height: info.height, channels: 4 }, | |
| }, | |
| ]) | |
| .toBuffer({ resolveWithObject: true }) | |
| .then(({ data, info }) => | |
| sharp(data, { | |
| raw: info, | |
| }).toFormat(format, { ...options }) | |
| ) |
gatsby/packages/gatsby-plugin-sharp/src/duotone.js
Lines 18 to 36 in b81e6bd
| .toBuffer({ resolveWithObject: true }) | |
| .then(({ data, info }) => { | |
| for (let i = 0; i < data.length; i = i + info.channels) { | |
| const r = data[i + 0] | |
| const g = data[i + 1] | |
| const b = data[i + 2] | |
| // @see https://en.wikipedia.org/wiki/Relative_luminance | |
| const avg = Math.round(0.2126 * r + 0.7152 * g + 0.0722 * b) | |
| data[i + 0] = duotoneGradient[avg][0] | |
| data[i + 1] = duotoneGradient[avg][1] | |
| data[i + 2] = duotoneGradient[avg][2] | |
| } | |
| return sharp(data, { | |
| raw: info, | |
| }).toFormat(format, { ...options }) | |
| }) |
Metadata
Metadata
Assignees
Labels
good first issueIssue that doesn't require previous experience with GatsbyIssue that doesn't require previous experience with Gatsbystale?Issue that may be closed soon due to the original author not responding any more.Issue that may be closed soon due to the original author not responding any more.type: bugAn issue or pull request relating to a bug in GatsbyAn issue or pull request relating to a bug in Gatsby