New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

image-convert

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

image-convert - npm Package Compare versions

Comparing version 0.1.313 to 0.1.321

39

index.js

@@ -6,3 +6,2 @@ // Copyright 2016 Arshpreet Wadehra

const request = require('request').defaults({ encoding: null });
const atob = require('atob');
const FileAPI = require('file-api')

@@ -24,2 +23,8 @@ , File = FileAPI.File

}
function GetFileExtension(url){
if(url){
let index = url.lastIndexOf(".")+1;
return url.substr(index);
}
}
function dataURLtoFile(dataurl, filename,output_format) {

@@ -37,3 +42,3 @@ var file = new File({

if(url == undefined)
callback("No URL FOUND",null);
callback("No URL FOUND",null,null);
if(quality == undefined)

@@ -44,17 +49,23 @@ quality = 100

let filename = GetFilename(url);
try{
request.get(url, function (err, res, body) {
var img = image(body);
var buffer;
if(size ==undefined || size == "original")//original size
buffer = image(body).encode(output_format,{quality:quality});
else
buffer = image(body).size(size).encode(output_format,{quality:quality});
callback(null,buffer,dataURLtoFile(buffer,filename,output_format));
});
let extension = GetFileExtension(url);
if(extension == "jpg" || extension == "gif" || extension == "png"){
try{
request.get(url, function (err, res, body) {
var img = image(body);
var buffer;
if(size ==undefined || size == "original")//original size
buffer = image(body).encode(output_format,{quality:quality});
else
buffer = image(body).size(size).encode(output_format,{quality:quality});
callback(null,buffer,dataURLtoFile(buffer,filename,output_format));
});
}
catch(e){
callback(e,null,null);
}
}
catch(e){
callback(e.message,null);
else{
callback(new Error("Unknown File Format"),null,null)
}
}
}
{
"name": "image-convert",
"version": "0.1.313",
"version": "0.1.321",
"description": "convert image to different format like gif2jpg jpg2png also manage the quality & size",

@@ -25,3 +25,2 @@ "main": "index.js",

"dependencies": {
"atob": "^2.0.3",
"file-api": "^0.10.4",

@@ -28,0 +27,0 @@ "images": "^3.0.0",

@@ -5,2 +5,4 @@ # image-convert

supported extensions jpg, png and gif
npm install image-convert --save

@@ -17,3 +19,3 @@

output_format:<output_format>,
size: <size{integer}>},function(err,buffer,file){//buffer=> base64 encode, file=> file object
size: <size{integer}>},function(err,buffer,file){//buffer=> base64 encode, file=> file object
if(!err)

@@ -20,0 +22,0 @@ console.log(res);//img buffer

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