Skip to content

Commit

Permalink
Allow Sharp to process semi-corrupted images, #65
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanielrindlaub committed Sep 7, 2023
1 parent 601d3cc commit 4d0b0ee
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ingest-image/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const IngestType = new Enum(['NONE', 'IMAGE', 'BATCH'], 'IngestType');

const APIKEY = process.env.APIKEY;

const SHARP_CONFIG = { failOn: 'none' };

export default class Task {
constructor(stage = 'dev') {
this.STAGE = stage;
Expand Down Expand Up @@ -130,7 +132,7 @@ export default class Task {
}

async sharp_stats(md) {
return await sharp(path.join(this.tmp_dir, md.FileName)).stats();
return await sharp(path.join(this.tmp_dir, md.FileName), SHARP_CONFIG).stats();
}

async save_image(md) {
Expand Down Expand Up @@ -243,7 +245,7 @@ export default class Task {

async resize(md, filename, dims) {
const tmp_path = path.join(this.tmp_dir, filename);
await sharp(path.join(this.tmp_dir, md.FileName))
await sharp(path.join(this.tmp_dir, md.FileName), SHARP_CONFIG)
.resize(dims[0], dims[1], {
fit: 'inside'
})
Expand Down

0 comments on commit 4d0b0ee

Please sign in to comment.