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

assetgraph-sprite

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

assetgraph-sprite - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

44

lib/index.js
var _ = require('underscore'),
child_process = require('child_process'),
seq = require('seq'),

@@ -7,2 +8,41 @@ Canvas = require('canvas'),

require('bufferjs');
function getCanvasImageFromBuffer(buffer, cb) {
var canvasImage = new Canvas.Image();
canvasImage.onerror = function (err) {
process.nextTick(function () {
cb(err);
});
};
canvasImage.onload = function () {
process.nextTick(function () {
cb(null, canvasImage);
});
};
canvasImage.src = buffer;
}
function getCanvasImageFromImageAsset(imageAsset, cb) {
imageAsset.getSerializedSrc(passError(cb, function (src) {
if (imageAsset.type === 'Png' || imageAsset.type === 'Jpeg') {
getCanvasImageFromBuffer(src, cb);
} else {
// Use GraphicsMagick while waiting for gif support: https://github.com/LearnBoost/node-canvas/issues/78
var buffers = [],
convertProcess = child_process.spawn('gm', ['convert', imageAsset.type.toLowerCase() + ':-', 'png:-']);
convertProcess.stdout.on('data', function (buffer) {
buffers.push(buffer);
});
convertProcess.on('exit', function () {
getCanvasImageFromBuffer(Buffer.concat(buffers), cb);
}).on('error', cb);
convertProcess.stdin.write(src);
convertProcess.stdin.end();
}
}));
}
function calculateSpritePadding(paddingStr) {

@@ -36,3 +76,3 @@ if (paddingStr) {

if (cairoVersion[0] < 1 || cairoVersion[1] < 10) {
console.warn("transforms.spriteBackgroundImages: Cannot create sprites due to missing canvas.getContext('2d').drawImage() support. Please compile node-canvas with Cairo version 1.10.0 or above.");
console.warn("assetgraph-sprite: Cannot create sprites due to missing canvas.getContext('2d').drawImage() support. Please compile node-canvas with Cairo version 1.10.0 or above.");
return cb();

@@ -82,3 +122,3 @@ }

if (spriteGroups[spriteGroupName].placeHolder) {
console.warn("spriteBackgroundImages: Multiple definitions of " + spriteGroupName + " sprite");
console.warn("assetgraph-sprite: Multiple definitions of " + spriteGroupName + " sprite");
}

@@ -85,0 +125,0 @@ spriteGroups[spriteGroupName].placeHolder = _.extend(spriteInfo, {

3

package.json

@@ -5,3 +5,3 @@ {

"repository": "git://github.com/One-com/assetgraph-sprite.git",
"version": "0.0.1",
"version": "0.0.2",
"maintainers": [

@@ -15,2 +15,3 @@ {

"underscore": ">=1.1.3",
"bufferjs": "=1.0.1",
"canvas": "=0.6.0",

@@ -17,0 +18,0 @@ "seq": ">=0.3.0 <0.4"

@@ -28,3 +28,3 @@ var vows = require('vows'),

topic: function (assetGraph) {
assetGraph.queue(transforms.spriteBackgroundImages()).run(this.callback);
assetGraph.queue(require('../lib')()).run(this.callback);
},

@@ -31,0 +31,0 @@ 'the number of Png assets should be down to one': function (assetGraph) {

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