Socket
Socket
Sign inDemoInstall

heic-convert

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

heic-convert - npm Package Compare versions

Comparing version 1.2.4 to 2.0.0

lib.js

58

index.js

@@ -1,57 +0,5 @@

const jpegJs = require('jpeg-js');
const { PNG } = require('pngjs');
const decode = require('heic-decode');
const { one, all } = require('./lib.js')(decode);
const to = {
JPEG: ({ data, width, height, quality }) => jpegJs.encode({ data, width, height }, quality).data,
PNG: ({ data, width, height }) => {
const png = new PNG({ width, height });
png.data = data;
return PNG.sync.write(png, {
width: width,
height: height,
deflateLevel: 9,
deflateStrategy: 3,
filterType: -1,
colorType: 6,
inputHasAlpha: true
});
}
};
const convertImage = async ({ image, format, quality }) => {
return await to[format]({
width: image.width,
height: image.height,
data: Buffer.from(image.data),
quality: Math.floor(quality * 100)
});
};
const convert = async ({ buffer, format, quality, all }) => {
if (!to[format]) {
throw new Error(`output format needs to be one of [${Object.keys(to)}]`);
}
if (!all) {
const image = await decode({ buffer });
return await convertImage({ image, format, quality });
}
const images = await decode.all({ buffer });
return images.map(image => {
return {
convert: async () => await convertImage({
image: await image.decode(),
format,
quality
})
};
});
};
module.exports = async ({ buffer, format, quality = 0.92 }) => await convert({ buffer, format, quality, all: false });
module.exports.all = async ({ buffer, format, quality = 0.92 }) => await convert({ buffer, format, quality, all: true });
module.exports = one;
module.exports.all = all;
{
"name": "heic-convert",
"version": "1.2.4",
"version": "2.0.0",
"description": "Convert HEIC/HEIF images to JPEG and PNG",

@@ -8,3 +8,3 @@ "main": "index.js",

"pretest": "node scripts/images.js",
"test": "mocha --timeout 20000 --slow 0 \"test/**/*.js\""
"test": "mocha --timeout 40000 --slow 0 \"test/**/*.js\""
},

@@ -42,9 +42,9 @@ "repository": {

"dependencies": {
"heic-decode": "^1.1.2",
"jpeg-js": "^0.4.1",
"pngjs": "^3.4.0"
"heic-decode": "^2.0.0",
"jpeg-js": "^0.4.4",
"pngjs": "^6.0.0"
},
"engines": {
"node": ">=8.0.0"
"node": ">=12.0.0"
}
}

@@ -5,8 +5,8 @@ # heic-convert

[![travis][travis.svg]][travis.link]
[![ci][ci.svg]][ci.link]
[![npm-downloads][npm-downloads.svg]][npm.link]
[![npm-version][npm-version.svg]][npm.link]
[travis.svg]: https://travis-ci.com/catdad-experiments/heic-convert.svg?branch=master
[travis.link]: https://travis-ci.com/catdad-experiments/heic-convert
[ci.svg]: https://github.com/catdad-experiments/heic-convert/actions/workflows/ci.yml/badge.svg
[ci.link]: https://github.com/catdad-experiments/heic-convert/actions/workflows/ci.yml
[npm-downloads.svg]: https://img.shields.io/npm/dm/heic-convert.svg

@@ -13,0 +13,0 @@ [npm.link]: https://www.npmjs.com/package/heic-convert

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc