Comparing version 1.3.9 to 1.3.10
@@ -1,1 +0,1 @@ | ||
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var _regeneratorRuntime=_interopDefault(require("@babel/runtime/regenerator")),_asyncToGenerator=_interopDefault(require("@babel/runtime/helpers/asyncToGenerator")),_objectSpread=_interopDefault(require("@babel/runtime/helpers/objectSpread")),_classCallCheck=_interopDefault(require("@babel/runtime/helpers/classCallCheck")),_createClass=_interopDefault(require("@babel/runtime/helpers/createClass")),_defineProperty=_interopDefault(require("@babel/runtime/helpers/defineProperty"));require("gm-base64");var gm=_interopDefault(require("gm")),path=_interopDefault(require("path")),fs=_interopDefault(require("fs-extra")),Promise=_interopDefault(require("bluebird")),PDF2Pic=function(){function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};_classCallCheck(this,t),this.options=_objectSpread({},t.defaultOptions,e)}var r,n,a,i,s,o,u,c;return _createClass(t,[{key:"identify",value:function(e,t){var a=gm(e);return new Promise(function(r,n){t?a.identify(t,function(e,t){return e?n(e):r(t)}):a.identify(function(e,t){return e?n(e):r(t)})})}},{key:"graphicMagickBaseCommand",value:function(e,t){var r=this.options,n=r.density,a=r.size,i=r.quality,s=r.compression,o=a.split(/x/i)[0],u=a.split(/x/i)[1];return u?gm(e,t).density(n,n).resize(o,u).quality(i).compress(s):gm(e,t).density(n,n).resize(a).quality(i).compress(s)}},{key:"writeImage",value:function(e,n,a,i){var s=this;return new Promise(function(t,r){s.graphicMagickBaseCommand(e,a).write(n,function(e){return e?r(e):t({name:path.basename(n),size:fs.statSync(n).size/1e3,path:n,page:i})})})}},{key:"toBase64",value:function(e,t,a){var i=this,s=this.options.format;return new Promise(function(r,n){i.graphicMagickBaseCommand(e,t).toBase64(s,function(e,t){return e?n(e):r({base64:t,page:a})})})}},{key:"convert",value:(c=_asyncToGenerator(_regeneratorRuntime.mark(function e(t){var r,n,a=arguments;return _regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=1<a.length&&void 0!==a[1]?a[1]:1,this.isValidPDF(t),this.fileExists(t),n=path.basename(t,path.extname(path.basename(t))),this.getOption("savedir")?this.setOption("savedir",this.getOption("savedir")+path.sep):this.setOption("savedir",n+path.sep),fs.mkdirsSync(this.getOption("savedir")),this.getOption("savename")||this.setOption("savename",n),e.next=9,this.getPageCount(t);case 9:if(e.sent<r)throw new Error("Cannot convert non-existent page");e.next=12;break;case 12:return e.next=14,this.toImage(t,r);case 14:return e.abrupt("return",e.sent);case 15:case"end":return e.stop()}},e,this)})),function(e){return c.apply(this,arguments)})},{key:"convertToBase64",value:(u=_asyncToGenerator(_regeneratorRuntime.mark(function e(t){var r,n,a=arguments;return _regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=1<a.length&&void 0!==a[1]?a[1]:1,this.isValidPDF(t),this.fileExists(t),n=path.basename(t,path.extname(path.basename(t))),this.getOption("savedir")?this.setOption("savedir",this.getOption("savedir")+path.sep):this.setOption("savedir",n+path.sep),fs.mkdirsSync(this.getOption("savedir")),this.getOption("savename")||this.setOption("savename",n),e.next=9,this.getPageCount(t);case 9:if(e.sent<r)throw new Error("Cannot convert non-existent page");e.next=12;break;case 12:return e.next=14,this.streamToBase64(t,r,!0);case 14:return e.abrupt("return",e.sent);case 15:case"end":return e.stop()}},e,this)})),function(e){return u.apply(this,arguments)})},{key:"convertToBase64Bulk",value:(o=_asyncToGenerator(_regeneratorRuntime.mark(function e(t){var r,n,a,i=this,s=arguments;return _regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(r=1<s.length&&void 0!==s[1]?s[1]:-1,n=[],a=Array.isArray(r)?r:[1],-1===r)return e.next=6,this.getPage(t);e.next=9;break;case 6:e.t0=e.sent,e.next=10;break;case 9:e.t0=a;case 10:return r=(r=e.t0).map(function(e){return i.convertToBase64(t,e)}),e.next=14,Promise.all(r);case 14:return n=e.sent,e.abrupt("return",n);case 16:case"end":return e.stop()}},e,this)})),function(e){return o.apply(this,arguments)})},{key:"convertBulk",value:(s=_asyncToGenerator(_regeneratorRuntime.mark(function e(t){var r,n,a,i=this,s=arguments;return _regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(r=1<s.length&&void 0!==s[1]?s[1]:-1,n=[],a=Array.isArray(r)?r:[1],-1===r)return e.next=6,this.getPage(t);e.next=9;break;case 6:e.t0=e.sent,e.next=10;break;case 9:e.t0=a;case 10:return r=(r=e.t0).map(function(e){return i.convert(t,e)}),e.next=14,Promise.all(r);case 14:return n=e.sent,e.abrupt("return",n);case 16:case"end":return e.stop()}},e,this)})),function(e){return s.apply(this,arguments)})},{key:"getPageCount",value:(i=_asyncToGenerator(_regeneratorRuntime.mark(function e(t){return _regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPage(t).length;case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}},e,this)})),function(e){return i.apply(this,arguments)})},{key:"getPage",value:(a=_asyncToGenerator(_regeneratorRuntime.mark(function e(t){var r;return _regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.identify(t,"%p ");case 2:return r=e.sent,e.abrupt("return",r.split(" "));case 4:case"end":return e.stop()}},e,this)})),function(e){return a.apply(this,arguments)})},{key:"toImage",value:(n=_asyncToGenerator(_regeneratorRuntime.mark(function e(t){var r,n,a,i,s,o,u,c,p=arguments;return _regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=1<p.length&&void 0!==p[1]?p[1]:1,n=this.getOption(),a=n.savedir,i=n.savename,s=n.format,o=fs.createReadStream(t),u="".concat(a.replace(/\/*$/,"/")).concat(i,"_").concat(r,".").concat(s),c="".concat(this.getFilePath(o),"[").concat(r-1,"]"),e.next=7,this.writeImage(o,u,c,r);case 7:return e.abrupt("return",e.sent);case 8:case"end":return e.stop()}},e,this)})),function(e){return n.apply(this,arguments)})},{key:"streamToBase64",value:(r=_asyncToGenerator(_regeneratorRuntime.mark(function e(t){var r,n,a,i=arguments;return _regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=1<i.length&&void 0!==i[1]?i[1]:1,n=fs.createReadStream(t),a="".concat(this.getFilePath(n),"[").concat(r-1,"]"),e.next=5,this.toBase64(n,a,r);case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}},e,this)})),function(e){return r.apply(this,arguments)})},{key:"getFilePath",value:function(e){if(!e)throw new Error("Invalid Stream");return e.path}},{key:"isValidPDF",value:function(e){if(".pdf"!==path.extname(path.basename(e)).toLowerCase())throw new Error("File supplied is not a valid PDF");return!0}},{key:"fileExists",value:function(e){if(!fs.existsSync(e))throw new Error("File supplied cannot be found");return!0}},{key:"getOption",value:function(e){return e?this.options[e]:this.options}},{key:"setOption",value:function(e,t){return this.options[e]=t,this}}]),t}();_defineProperty(PDF2Pic,"defaultOptions",{quality:0,format:"png",size:"768x512",density:72,savedir:"./",savename:"untitled",compression:"jpeg"}),module.exports=PDF2Pic; | ||
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var _regeneratorRuntime=_interopDefault(require("@babel/runtime/regenerator")),_asyncToGenerator=_interopDefault(require("@babel/runtime/helpers/asyncToGenerator")),_classCallCheck=_interopDefault(require("@babel/runtime/helpers/classCallCheck")),_createClass=_interopDefault(require("@babel/runtime/helpers/createClass")),_defineProperty=_interopDefault(require("@babel/runtime/helpers/defineProperty"));require("gm-base64");var gm=_interopDefault(require("gm")),path=_interopDefault(require("path")),fs=_interopDefault(require("fs-extra"));function ownKeys(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(r,!0).forEach(function(e){_defineProperty(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ownKeys(r).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}var PDF2Pic=function(){function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};_classCallCheck(this,t),this.options=_objectSpread({},t.defaultOptions,{},e)}var r,n,a,i,s,o,u,c;return _createClass(t,[{key:"identify",value:function(e,t){var a=gm(e);return new Promise(function(r,n){t?a.identify(t,function(e,t){return e?n(e):r(t.replace(/^[\w\W]+?1/,"1"))}):a.identify(function(e,t){return e?n(e):r(t)})})}},{key:"graphicMagickBaseCommand",value:function(e,t){var r=this.options,n=r.density,a=r.size,i=r.quality,s=r.compression,o=a.split(/x/i)[0],u=a.split(/x/i)[1];return u?gm(e,t).density(n,n).resize(o,u).quality(i).compress(s):gm(e,t).density(n,n).resize(a).quality(i).compress(s)}},{key:"writeImage",value:function(e,n,a,i){var s=this;return new Promise(function(t,r){s.graphicMagickBaseCommand(e,a).write(n,function(e){return e?r(e):t({name:path.basename(n),size:fs.statSync(n).size/1e3,path:n,page:i})})})}},{key:"toBase64",value:function(e,t,a){var i=this,s=this.options.format;return new Promise(function(r,n){i.graphicMagickBaseCommand(e,t).toBase64(s,function(e,t){return e?n(e):r({base64:t,page:a})})})}},{key:"convert",value:(c=_asyncToGenerator(_regeneratorRuntime.mark(function e(t){var r,n,a=arguments;return _regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=1<a.length&&void 0!==a[1]?a[1]:1,this.isValidPDF(t),this.fileExists(t),n=path.basename(t,path.extname(path.basename(t))),this.getOption("savedir")?this.setOption("savedir",this.getOption("savedir")+path.sep):this.setOption("savedir",n+path.sep),fs.mkdirsSync(this.getOption("savedir")),this.getOption("savename")||this.setOption("savename",n),e.next=9,this.getPageCount(t);case 9:if(e.sent<r)throw new Error("Cannot convert non-existent page");e.next=12;break;case 12:return e.next=14,this.toImage(t,r);case 14:return e.abrupt("return",e.sent);case 15:case"end":return e.stop()}},e,this)})),function(e){return c.apply(this,arguments)})},{key:"convertToBase64",value:(u=_asyncToGenerator(_regeneratorRuntime.mark(function e(t){var r,n,a=arguments;return _regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=1<a.length&&void 0!==a[1]?a[1]:1,this.isValidPDF(t),this.fileExists(t),n=path.basename(t,path.extname(path.basename(t))),this.getOption("savedir")?this.setOption("savedir",this.getOption("savedir")+path.sep):this.setOption("savedir",n+path.sep),fs.mkdirsSync(this.getOption("savedir")),this.getOption("savename")||this.setOption("savename",n),e.next=9,this.getPageCount(t);case 9:if(e.sent<r)throw new Error("Cannot convert non-existent page");e.next=12;break;case 12:return e.next=14,this.streamToBase64(t,r,!0);case 14:return e.abrupt("return",e.sent);case 15:case"end":return e.stop()}},e,this)})),function(e){return u.apply(this,arguments)})},{key:"convertToBase64Bulk",value:(o=_asyncToGenerator(_regeneratorRuntime.mark(function e(t){var r,n,a,i=this,s=arguments;return _regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(r=1<s.length&&void 0!==s[1]?s[1]:-1,n=[],a=Array.isArray(r)?r:[1],-1===r)return e.next=6,this.getPage(t);e.next=9;break;case 6:e.t0=e.sent,e.next=10;break;case 9:e.t0=a;case 10:return r=(r=e.t0).map(function(e){return i.convertToBase64(t,e)}),e.next=14,Promise.all(r);case 14:return n=e.sent,e.abrupt("return",n);case 16:case"end":return e.stop()}},e,this)})),function(e){return o.apply(this,arguments)})},{key:"convertBulk",value:(s=_asyncToGenerator(_regeneratorRuntime.mark(function e(t){var r,n,a,i=this,s=arguments;return _regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(r=1<s.length&&void 0!==s[1]?s[1]:-1,n=[],a=Array.isArray(r)?r:[1],-1===r)return e.next=6,this.getPage(t);e.next=9;break;case 6:e.t0=e.sent,e.next=10;break;case 9:e.t0=a;case 10:return r=(r=e.t0).map(function(e){return i.convert(t,e)}),e.next=14,Promise.all(r);case 14:return n=e.sent,e.abrupt("return",n);case 16:case"end":return e.stop()}},e,this)})),function(e){return s.apply(this,arguments)})},{key:"getPageCount",value:(i=_asyncToGenerator(_regeneratorRuntime.mark(function e(t){return _regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPage(t).length;case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}},e,this)})),function(e){return i.apply(this,arguments)})},{key:"getPage",value:(a=_asyncToGenerator(_regeneratorRuntime.mark(function e(t){var r;return _regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.identify(t,"%p ");case 2:return r=e.sent,e.abrupt("return",r.split(" "));case 4:case"end":return e.stop()}},e,this)})),function(e){return a.apply(this,arguments)})},{key:"toImage",value:(n=_asyncToGenerator(_regeneratorRuntime.mark(function e(t){var r,n,a,i,s,o,u,c,p=arguments;return _regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=1<p.length&&void 0!==p[1]?p[1]:1,n=this.getOption(),a=n.savedir,i=n.savename,s=n.format,o=fs.createReadStream(t),u="".concat(a.replace(/\/*$/,"/")).concat(i,"_").concat(r,".").concat(s),c="".concat(this.getFilePath(o),"[").concat(r-1,"]"),e.next=7,this.writeImage(o,u,c,r);case 7:return e.abrupt("return",e.sent);case 8:case"end":return e.stop()}},e,this)})),function(e){return n.apply(this,arguments)})},{key:"streamToBase64",value:(r=_asyncToGenerator(_regeneratorRuntime.mark(function e(t){var r,n,a,i=arguments;return _regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=1<i.length&&void 0!==i[1]?i[1]:1,n=fs.createReadStream(t),a="".concat(this.getFilePath(n),"[").concat(r-1,"]"),e.next=5,this.toBase64(n,a,r);case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}},e,this)})),function(e){return r.apply(this,arguments)})},{key:"getFilePath",value:function(e){if(!e)throw new Error("Invalid Stream");return e.path}},{key:"isValidPDF",value:function(e){if(".pdf"!==path.extname(path.basename(e)).toLowerCase())throw new Error("File supplied is not a valid PDF");return!0}},{key:"fileExists",value:function(e){if(!fs.existsSync(e))throw new Error("File supplied cannot be found");return!0}},{key:"getOption",value:function(e){return e?this.options[e]:this.options}},{key:"setOption",value:function(e,t){return this.options[e]=t,this}}]),t}();_defineProperty(PDF2Pic,"defaultOptions",{quality:0,format:"png",size:"768x512",density:72,savedir:"./",savename:"untitled",compression:"jpeg"}),module.exports=PDF2Pic; |
{ | ||
"name": "pdf2pic", | ||
"version": "1.3.9", | ||
"version": "1.3.10", | ||
"description": "A utility for converting pdf to image and base64 format.", | ||
@@ -36,4 +36,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"@babel/runtime": "^7.4.4", | ||
"bluebird": "^3.5.1", | ||
"@babel/runtime": "^7.6.3", | ||
"fs-extra": "^4.0.2", | ||
@@ -44,11 +43,11 @@ "gm": "^1.23.0", | ||
"devDependencies": { | ||
"@babel/cli": "^7.4.4", | ||
"@babel/core": "^7.4.4", | ||
"@babel/cli": "^7.6.4", | ||
"@babel/core": "^7.6.4", | ||
"@babel/plugin-external-helpers": "^7.2.0", | ||
"@babel/plugin-proposal-class-properties": "^7.4.4", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.4.4", | ||
"@babel/plugin-transform-runtime": "^7.4.4", | ||
"@babel/preset-env": "^7.4.4", | ||
"@babel/register": "^7.4.4", | ||
"babel-eslint": "^10.0.1", | ||
"@babel/plugin-proposal-class-properties": "^7.5.5", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.6.2", | ||
"@babel/plugin-transform-runtime": "^7.6.2", | ||
"@babel/preset-env": "^7.6.3", | ||
"@babel/register": "^7.6.2", | ||
"babel-eslint": "^10.0.3", | ||
"babel-plugin-module-resolver": "^3.2.0", | ||
@@ -58,9 +57,9 @@ "chai": "^4.2.0", | ||
"eslint-plugin-babel": "^5.3.0", | ||
"eslint-plugin-import": "^2.17.2", | ||
"eslint-plugin-import": "^2.18.2", | ||
"mocha": "^4.1.0", | ||
"rimraf": "^2.6.1", | ||
"rollup": "^1.1.2", | ||
"rollup-plugin-babel": "^4.0.0-beta.7", | ||
"rollup-plugin-uglify": "^6.0.2" | ||
"rimraf": "^2.7.1", | ||
"rollup": "^1.26.0", | ||
"rollup-plugin-babel": "^4.3.3", | ||
"rollup-plugin-uglify": "^6.0.3" | ||
} | ||
} |
@@ -9,3 +9,3 @@ # PDF2Pic | ||
* node >= 7.x | ||
* node >= 8.x | ||
* graphicsmagick | ||
@@ -23,3 +23,2 @@ * ghostscript | ||
* bluebird | ||
* fs-extra | ||
@@ -26,0 +25,0 @@ * gm |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28532
4
56
127
- Removedbluebird@^3.5.1
- Removedbluebird@3.7.2(transitive)
Updated@babel/runtime@^7.6.3