Socket
Socket
Sign inDemoInstall

immp

Package Overview
Dependencies
4
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.1 to 1.2.4

2

package.json
{
"name": "immp",
"description": "Image Manipulation Middleware Proxy",
"version": "1.2.1",
"version": "1.2.4",
"repository": "garrows/IMMP",

@@ -6,0 +6,0 @@ "keywords": [

@@ -76,6 +76,20 @@ var _ = require('underscore'),

if(stat && now - createdAt < config.ttl) {
gm(config.cacheFolder + '/' + image.hash)
var gmImage = gm(config.cacheFolder + '/' + image.hash)
.options(gmOptions)
.stream()
.pipe(_res);
.format({
bufferStream: true
}, function (_error, _format) {
if(_error) {
console.log(_error);
return _callback(_error);
}
image.format = _format;
if(!_res.headersSent) {
_res.header('Content-Type', 'image/' + _format.toLowerCase());
}
gmImage.stream()
.pipe(_res);
});
} else {

@@ -141,5 +155,5 @@ _callback();

image.format = _format;
_res.set({
'Content-Type': 'image/' + _format.toLowerCase()
});
if(!_res.headersSent) {
_res.header('Content-Type', 'image/' + _format.toLowerCase());
}

@@ -234,2 +248,3 @@ _callback(null);

if(_error) {
console.log('error', _error);
_next(_error);

@@ -236,0 +251,0 @@ }

@@ -16,2 +16,4 @@ var async = require('async'),

var server = 'http://localhost:' + (process.env.PORT || 3000);
describe('immp', function () {

@@ -40,3 +42,3 @@

http.get('http://localhost:3000/im/?image=/images/robot.jpg&resize=200x0', function (_httpResponse) {
http.get(server + '/im/?image=/images/robot.jpg&resize=200x0', function (_httpResponse) {

@@ -63,3 +65,3 @@ _httpResponse.headers['content-type'].should.eql('image/jpeg');

http.get('http://localhost:3000/im/?image=/images/robot.jpg&resize=0x200', function (_httpResponse) {
http.get(server + '/im/?image=/images/robot.jpg&resize=0x200', function (_httpResponse) {

@@ -86,3 +88,3 @@ _httpResponse.headers['content-type'].should.eql('image/jpeg');

http.get('http://localhost:3000/im/?image=/images/robot.jpg&resize=2000x2000', function (_httpResponse) {
http.get(server + '/im/?image=/images/robot.jpg&resize=2000x2000', function (_httpResponse) {

@@ -110,3 +112,3 @@ _httpResponse.headers['content-type'].should.eql('image/jpeg');

http.get('http://localhost:3000/im/?image=/images/robot.jpg&resize=2000x2000&upscale=true', function (_httpResponse) {
http.get(server + '/im/?image=/images/robot.jpg&resize=2000x2000&upscale=true', function (_httpResponse) {

@@ -134,3 +136,3 @@ _httpResponse.headers['content-type'].should.eql('image/jpeg');

http.get('http://localhost:3000/im/?image=/images/robot.jpg&resize=100x200', function (_httpResponse) {
http.get(server + '/im/?image=/images/robot.jpg&resize=100x200', function (_httpResponse) {

@@ -160,3 +162,3 @@ _httpResponse.headers['content-type'].should.eql('image/jpeg');

http.get('http://localhost:3000/im/?image=/images/robot.jpg&crop=1x1', function (_httpResponse) {
http.get(server + '/im/?image=/images/robot.jpg&crop=1x1', function (_httpResponse) {

@@ -184,3 +186,3 @@ _httpResponse.headers['content-type'].should.eql('image/jpeg');

http.get('http://localhost:3000/im/?image=/images/robot.jpg&crop=9x16', function (_httpResponse) {
http.get(server + '/im/?image=/images/robot.jpg&crop=9x16', function (_httpResponse) {

@@ -209,3 +211,3 @@ _httpResponse.headers['content-type'].should.eql('image/jpeg');

http.get('http://localhost:3000/im/?image=/images/robot.jpg&crop=16x9', function (_httpResponse) {
http.get(server + '/im/?image=/images/robot.jpg&crop=16x9', function (_httpResponse) {

@@ -233,3 +235,3 @@ _httpResponse.headers['content-type'].should.eql('image/jpeg');

http.get('http://localhost:3000/im/?image=/images/robot.jpg&crop=1x1&resize=50x100', function (_httpResponse) {
http.get(server + '/im/?image=/images/robot.jpg&crop=1x1&resize=50x100', function (_httpResponse) {

@@ -262,3 +264,3 @@ _httpResponse.headers['content-type'].should.eql('image/jpeg');

http.get('http://localhost:3000/im/?image=/images/robot.jpg&quality=invalidQualityValue', function (_httpResponse) {
http.get(server + '/im/?image=/images/robot.jpg&quality=invalidQualityValue', function (_httpResponse) {

@@ -281,3 +283,3 @@ _httpResponse.headers['content-type'].should.eql('image/jpeg');

http.get('http://localhost:3000/im/?image=/images/robot.jpg&quality=50', function (_httpResponse) {
http.get(server + '/im/?image=/images/robot.jpg&quality=50', function (_httpResponse) {

@@ -310,3 +312,3 @@ _httpResponse.headers['content-type'].should.eql('image/jpeg');

http.get('http://localhost:3000/im/?image=/images/Landscape_8.jpg&quality=50', function (_httpResponse) {
http.get(server + '/im/?image=/images/Landscape_8.jpg&quality=50', function (_httpResponse) {

@@ -333,3 +335,3 @@ _httpResponse.headers['content-type'].should.eql('image/jpeg');

http.get('http://localhost:3000/im/?image=http://localhost:3000/images/robot.jpg&crop=1x1&resize=50x100', function (_httpResponse) {
http.get(server + '/im/?image=' + server + '/images/robot.jpg&crop=1x1&resize=50x100', function (_httpResponse) {

@@ -357,3 +359,3 @@ _httpResponse.headers['content-type'].should.eql('image/jpeg');

http.get('http://localhost:3000/im/?image=https://www.google.com/images/srpr/logo11w.png&crop=1x1&resize=50x100', function (_httpResponse) {
http.get(server + '/im/?image=https://www.google.com/images/srpr/logo11w.png&crop=1x1&resize=50x100', function (_httpResponse) {

@@ -375,6 +377,23 @@ _httpResponse.headers['content-type'].should.eql('image/png');

});
it('should still have the right content-type & size when cached', function (_done) {
http.get(server + '/im/?image=/images/Landscape_8.jpg&quality=50', function (_httpResponse) {
_httpResponse.headers['content-type'].should.eql('image/jpeg');
gm(_httpResponse)
.options(gmOptions)
.size(function (_error, _size) {
if(_error) return _done(_error);
_size.width.should.equal(600);
_size.height.should.equal(450);
_done();
});
});
});
});
SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc