Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

limby-resize

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

limby-resize - npm Package Compare versions

Comparing version 0.0.3 to 0.0.5

47

lib/canvas_resize.js

@@ -0,1 +1,2 @@

var when = require('when');
/*

@@ -5,3 +6,3 @@ * MIT License

* https://github.com/danschumann/limby-resize
* 0.0.1
* 0.0.4
*/

@@ -46,3 +47,3 @@ var canvasResize = function(original, canvas) {

// For every pixel in the original, we tally it up in the new one
for (var y1 = 0; y1 < h1; y1++){
var nextY = function(y1){
for (var x1 = 0; x1 < w1; x1++) {

@@ -147,21 +148,37 @@

};
if (y1++ < h1)
setTimeout(nextY.bind(this, y1), 0); // this allows other processes to tick
else
done();
};
// fully distribute the color of pixels that are partially full because their neighbor is transparent
for (var i = 0; i < (_data2.length >> 2); i++){
if (alphas[i] && alphas[i] < 1) {
data2[(i<<2)] /= alphas[i]; // r
data2[(i<<2) + 1] /= alphas[i]; // g
data2[(i<<2) + 2] /= alphas[i]; // b
nextY(0);
var done = function(){
// fully distribute the color of pixels that are partially full because their neighbor is transparent
for (var i = 0; i < (_data2.length >> 2); i++){
if (alphas[i] && alphas[i] < 1) {
data2[(i<<2)] /= alphas[i]; // r
data2[(i<<2) + 1] /= alphas[i]; // g
data2[(i<<2) + 2] /= alphas[i]; // b
}
}
}
// re populate the actual imgData
for (var i = 0; i < data2.length; i++){
_data2[i] = Math.round(data2[i]);
}
// re populate the actual imgData
for (var i = 0; i < data2.length; i++){
_data2[i] = Math.round(data2[i]);
}
var context = canvas.getContext("2d")
context.putImageData(img2, 0, 0);
var context = canvas.getContext("2d")
context.putImageData(img2, 0, 0);
deferred.resolve();
};
var deferred = when.defer();
return deferred.promise
};

@@ -168,0 +185,0 @@

@@ -46,13 +46,15 @@ /*

resizedCanvas = new Canvas(width, height);
canvasResize(canvas, resizedCanvas);
}
};
var deferred = when.defer();
(resizedCanvas || canvas).toBuffer(function(err, buf){
return fs.writeFile(options.destination, buf)
.then(deferred.resolve).otherwise(deferred.reject);
});
return when(canvasResize(canvas, resizedCanvas))
.then(function(){
var deferred = when.defer();
(resizedCanvas || canvas).toBuffer(function(err, buf){
return fs.writeFile(options.destination, buf)
.then(deferred.resolve).otherwise(deferred.reject);
});
return deferred.promise;
return deferred.promise;
});
};

@@ -59,0 +61,0 @@ })

{
"name": "limby-resize",
"version": "0.0.3",
"version": "0.0.5",
"description": "Wrapper for resizing using ImageMagick OR Canvas.",

@@ -5,0 +5,0 @@ "main": "./limby-resize.js",

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