Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from glmaljkovich/heic-convert
Use heic-convert npm package to process images
- Loading branch information
Showing
4 changed files
with
43 additions
and
29 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const { promisify } = require('util'); | ||
const fs = require('fs'); | ||
const convert = require('heic-convert'); | ||
|
||
process.on('message', async ({ inputPath, outputPath, exit }) => { | ||
if (exit) { | ||
process.exit(0); | ||
} | ||
const inputBuffer = await promisify(fs.readFile)(inputPath); | ||
const outputBuffer = await convert({ | ||
buffer: inputBuffer, // the HEIC file buffer | ||
format: 'JPEG', // output format | ||
quality: 1 // the jpeg compression quality, between 0 and 1 | ||
}); | ||
await promisify(fs.writeFile)(outputPath, outputBuffer); | ||
process.send(inputPath); | ||
}); |