[Bug] Using sharp only works the first time, no error msg
See original GitHub issueI’m trying to generate multiple sizes of an array of image files. However this just works the first image, the next ones will fail. I’m using a static function, so there should be few error potential. The error appears just after the input file changes. All iterations for the first file work properly. Do I need to manually clear some sharp cache after all sizes were generated?
public static async createSizesOfImage(path: string, sizes?: number[]): Promise<number[]> {
if (!sizes || sizes.length === 0) sizes = [250, 640, 1280, 1600, 2200];
let error: Error, info: any;
const generatedSizes: number[] = [];
for (const size of sizes) {
const newFilePath = path.replace('.', '_s' + size + '.');
LoggerService.log('ImageService - createSizesOfImage(): Generating image s' + size);
console.warn('hi i am here');
[error, info] = await to(
sharp(path)
.resize(size, size, { fit: 'inside', withoutEnlargement: true })
.toFile(newFilePath)
);
if (error) {
console.error('ImageService - createSizesOfImage(): Failed to generate s' + size + ' of ' + path, error);
throw new Error();
}
generatedSizes.push(size);
}
return generatedSizes;
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
How to find the reason for a failed Build without any error or ...
I noticed that if "Build + Intellisense" is selected in the Error List, it causes the error messages to be swallowed. Change this...
Read more >Fix program errors and improve code - Visual Studio ...
This article describes some basic ways Visual Studio can help you find and fix problems in your code, including build errors, code analysis, ......
Read more >Bug #306401 “Brother MFC8840D errors on 1st print job”
Printing the 1st time to printer after printer power-up errors. The second and all subsequent attempts to print succeed with no errors.
Read more >Common .NET Software Errors and How to Fix Them
We've aggregated the 50 top .NET software errors. It includes exceptions, broken data bindings, memory leaks, etc. Find solutions on ways to ...
Read more >Bug listing with status RESOLVED with resolution FIXED as at ...
Bug listing with status RESOLVED with resolution FIXED as at 2022/12/24 19:46:07 ... Bug:120 - "kvm not working after new ebuild's of kde"...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Closing due to inactivity but please feel free to re-open with a standalone code sample if more help is required.
This should all work and I can’t see anything obviously wrong with the code presented here so far. Are you able to provide a standalone code sample, removing some of the other dependencies such as
to
? Which version/platform is this?