image-convert
Advanced tools
Comparing version 0.1.323 to 0.1.324
23
index.js
// Copyright 2016 Arshpreet Wadehra | ||
// | ||
// | ||
const image = require('images'); | ||
const request = require('request').defaults({ encoding: null }); | ||
const FileAPI = require('file-api') | ||
var image = require('images'); | ||
var request = require('request').defaults({ encoding: null }); | ||
var FileAPI = require('file-api') | ||
, File = FileAPI.File | ||
@@ -24,3 +24,3 @@ , FileList = FileAPI.FileList | ||
if(url){ | ||
let index = url.lastIndexOf(".")+1; | ||
var index = url.lastIndexOf(".")+1; | ||
return url.substr(index); | ||
@@ -38,4 +38,7 @@ } | ||
module.exports = { | ||
fromURL : (options, callback)=>{ | ||
let {url, quality,output_format,size} = options; | ||
fromURL : function(options, callback){ | ||
var url = options.url; | ||
var quality = options.quality; | ||
var output_format = options.output_format; | ||
var size = options.size; | ||
if(url == undefined) | ||
@@ -47,7 +50,11 @@ callback("No URL FOUND",null,null); | ||
output_format = "jpg" | ||
let filename = GetFilename(url); | ||
let extension = GetFileExtension(url); | ||
var filename = GetFilename(url); | ||
var extension = GetFileExtension(url); | ||
if((extension == "jpg" || extension == "gif" || extension == "png") && (output_format == "jpg" || output_format == "png")){ | ||
try{ | ||
request.get(url, function (err, res, body) { | ||
if(!res){ | ||
callback(new Error("Network Error"),null,null) | ||
return; | ||
} | ||
if(res.statusCode != 200){ | ||
@@ -54,0 +61,0 @@ callback(new Error("Invalid URL"),null,null) |
{ | ||
"name": "image-convert", | ||
"version": "0.1.323", | ||
"version": "0.1.324", | ||
"description": "convert image to different format like gif2jpg jpg2png also manage the quality & size", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -0,0 +0,0 @@ # image-convert |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
5211
78