img-about
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -1,10 +0,4 @@ | ||
# 2.0.0 (2019-04-10) | ||
## 2.0.1 (2019-04-10) | ||
### Bug Fixes | ||
* **imgCompress:** Bug: imageType merged in an unexpected way ([fc8ddc9](https://github.com/livelybone/img-about/commit/fc8ddc9)) | ||
* **imgCompress:** Bug: merge function was wrong ([7db42b9](https://github.com/livelybone/img-about/commit/7db42b9)) | ||
### Features | ||
@@ -14,4 +8,5 @@ | ||
* Update ([de6debf](https://github.com/livelybone/img-about/commit/de6debf)) | ||
* **imgCompress:** Update merge function ([0e4807d](https://github.com/livelybone/img-about/commit/0e4807d)) | ||
/** | ||
* Bundle of img-about | ||
* Generated: 2019-04-10 | ||
* Version: 2.0.0 | ||
* Version: 2.0.1 | ||
* License: MIT | ||
@@ -121,3 +121,3 @@ * Author: livelybone(2631541504@qq.com) | ||
Object.keys(defaultOptions).forEach(function (key) { | ||
options[key] = !compressOptions[key] | ||
options[key] = compressOptions[key] | ||
? compressOptions[key] : defaultOptions[key]; | ||
@@ -124,0 +124,0 @@ }); |
/** | ||
* Bundle of img-about | ||
* Generated: 2019-04-10 | ||
* Version: 2.0.0 | ||
* Version: 2.0.1 | ||
* License: MIT | ||
@@ -6,0 +6,0 @@ * Author: livelybone(2631541504@qq.com) |
/** | ||
* Bundle of img-about | ||
* Generated: 2019-04-10 | ||
* Version: 2.0.0 | ||
* Version: 2.0.1 | ||
* License: MIT | ||
@@ -9,2 +9,2 @@ * Author: livelybone(2631541504@qq.com) | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).imgCompress=t()}(this,function(){"use strict";"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var e,d=(function(e){var t;t=function(){return function(e,t,n){t=t||"",n=n||512;for(var o=atob(e),r=[],i=0;i<o.length;i+=n){for(var a=o.slice(i,i+n),s=new Array(a.length),c=0;c<a.length;c++)s[c]=a.charCodeAt(c);var f=new Uint8Array(s);r.push(f)}return new Blob(r,{type:t})}},e.exports?(e.exports=t(),e.exports.default=e.exports):window.b64toBlob=t()}(e={exports:{}},e.exports),e.exports);function o(o){return new Promise(function(t,n){try{var e=new FileReader;e.onload=function(e){t(e.target.result)},e.readAsDataURL(o)}catch(e){n(e)}})}function r(r){return new Promise(function(e,t){var n=document.createElement("img"),o=function(){e({width:n.width,height:n.height})};n.onload=o,n.onerror=function(){t(new Error("Image<"+r+"> loaded error"))},n.src=r,n.complete&&o()})}var i=!!document.createElement("canvas").getContext;return function(e,t){if(!i)return Promise.reject(new Error("Canvas is not supported in your browser"));if(!(e instanceof File||e instanceof Blob))return Promise.reject(new Error("The type of param `imgFile` is not matched It should be an instance of one of the File and Blob"));var u=["scale","fixedWidth","fixedHeight","fixedSize"],n={compressType:u[0],scale:1,imageSize:0,imageType:e.type||"image/png",quality:.8,toBlob:!0},l=n;return t&&Object.keys(n).forEach(function(e){l[e]=t[e]?n[e]:t[e]}),o(e).then(function(s){var c=document.createElement("canvas"),f=c.getContext("2d");return function(n){return new Promise(function(e,t){"string"==typeof n?e(r(n)):n instanceof Image?n.naturalWidth?e({width:n.naturalWidth,height:n.naturalHeight}):e(r(n.src)):n instanceof FileList||n instanceof File||n instanceof Blob?e(r(o(n[0]||n))):t(new Error("The type of param `img` is not matched. It should be an instance of one of the String, Image, File, FileList and Blob"))})}(s).then(function(e){var t,n,o=e.width,r=e.height;l.compressType===u[1]?n=(t=l.imageSize||o)*r/o:l.compressType===u[2]?t=(n=l.imageSize||r)*o/r:l.compressType===u[3]?r<o?t=(n=l.imageSize||r)*o/r:n=(t=l.imageSize||o)*r/o:(t=o*l.scale,n=r*l.scale);var i=document.createElement("img");i.src=s,c.width=t,c.height=n,f.drawImage(i,0,0,t,n);var a=c.toDataURL(l.imageType,l.quality);return l.toBlob?function(e){try{var t=e.split(","),n=t[0].match(/:(.*?);/)[1];return Promise.resolve(d(t[1],n))}catch(e){return Promise.reject(e)}}(a):a})})}}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).imgCompress=t()}(this,function(){"use strict";"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var e,d=(function(e){var t;t=function(){return function(e,t,n){t=t||"",n=n||512;for(var o=atob(e),r=[],i=0;i<o.length;i+=n){for(var a=o.slice(i,i+n),s=new Array(a.length),c=0;c<a.length;c++)s[c]=a.charCodeAt(c);var f=new Uint8Array(s);r.push(f)}return new Blob(r,{type:t})}},e.exports?(e.exports=t(),e.exports.default=e.exports):window.b64toBlob=t()}(e={exports:{}},e.exports),e.exports);function o(o){return new Promise(function(t,n){try{var e=new FileReader;e.onload=function(e){t(e.target.result)},e.readAsDataURL(o)}catch(e){n(e)}})}function r(r){return new Promise(function(e,t){var n=document.createElement("img"),o=function(){e({width:n.width,height:n.height})};n.onload=o,n.onerror=function(){t(new Error("Image<"+r+"> loaded error"))},n.src=r,n.complete&&o()})}var i=!!document.createElement("canvas").getContext;return function(e,t){if(!i)return Promise.reject(new Error("Canvas is not supported in your browser"));if(!(e instanceof File||e instanceof Blob))return Promise.reject(new Error("The type of param `imgFile` is not matched It should be an instance of one of the File and Blob"));var u=["scale","fixedWidth","fixedHeight","fixedSize"],n={compressType:u[0],scale:1,imageSize:0,imageType:e.type||"image/png",quality:.8,toBlob:!0},l=n;return t&&Object.keys(n).forEach(function(e){l[e]=t[e]?t[e]:n[e]}),o(e).then(function(s){var c=document.createElement("canvas"),f=c.getContext("2d");return function(n){return new Promise(function(e,t){"string"==typeof n?e(r(n)):n instanceof Image?n.naturalWidth?e({width:n.naturalWidth,height:n.naturalHeight}):e(r(n.src)):n instanceof FileList||n instanceof File||n instanceof Blob?e(r(o(n[0]||n))):t(new Error("The type of param `img` is not matched. It should be an instance of one of the String, Image, File, FileList and Blob"))})}(s).then(function(e){var t,n,o=e.width,r=e.height;l.compressType===u[1]?n=(t=l.imageSize||o)*r/o:l.compressType===u[2]?t=(n=l.imageSize||r)*o/r:l.compressType===u[3]?r<o?t=(n=l.imageSize||r)*o/r:n=(t=l.imageSize||o)*r/o:(t=o*l.scale,n=r*l.scale);var i=document.createElement("img");i.src=s,c.width=t,c.height=n,f.drawImage(i,0,0,t,n);var a=c.toDataURL(l.imageType,l.quality);return l.toBlob?function(e){try{var t=e.split(","),n=t[0].match(/:(.*?);/)[1];return Promise.resolve(d(t[1],n))}catch(e){return Promise.reject(e)}}(a):a})})}}); |
/** | ||
* Bundle of img-about | ||
* Generated: 2019-04-10 | ||
* Version: 2.0.0 | ||
* Version: 2.0.1 | ||
* License: MIT | ||
@@ -9,2 +9,2 @@ * Author: livelybone(2631541504@qq.com) | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).ImgAbout={})}(this,function(e){"use strict";"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var t,d=(function(e){var t;t=function(){return function(e,t,n){t=t||"",n=n||512;for(var o=atob(e),r=[],i=0;i<o.length;i+=n){for(var a=o.slice(i,i+n),s=new Array(a.length),c=0;c<a.length;c++)s[c]=a.charCodeAt(c);var f=new Uint8Array(s);r.push(f)}return new Blob(r,{type:t})}},e.exports?(e.exports=t(),e.exports.default=e.exports):window.b64toBlob=t()}(t={exports:{}},t.exports),t.exports);function o(o){return new Promise(function(t,n){try{var e=new FileReader;e.onload=function(e){t(e.target.result)},e.readAsDataURL(o)}catch(e){n(e)}})}function r(r){return new Promise(function(e,t){var n=document.createElement("img"),o=function(){e({width:n.width,height:n.height})};n.onload=o,n.onerror=function(){t(new Error("Image<"+r+"> loaded error"))},n.src=r,n.complete&&o()})}var i=!!document.createElement("canvas").getContext;function a(n){return new Promise(function(e,t){if("string"==typeof n)e(r(n));else if(n instanceof Image)n.naturalWidth?e({width:n.naturalWidth,height:n.naturalHeight}):e(r(n.src));else if(n instanceof FileList||n instanceof File||n instanceof Blob){e(r(o(n[0]||n)))}else t(new Error("The type of param `img` is not matched. It should be an instance of one of the String, Image, File, FileList and Blob"))})}e.canvasSupport=i,e.getNaturalSize=a,e.getSizeOfUrl=r,e.imgCompress=function(e,t){if(!i)return Promise.reject(new Error("Canvas is not supported in your browser"));if(!(e instanceof File||e instanceof Blob))return Promise.reject(new Error("The type of param `imgFile` is not matched It should be an instance of one of the File and Blob"));var l=["scale","fixedWidth","fixedHeight","fixedSize"],n={compressType:l[0],scale:1,imageSize:0,imageType:e.type||"image/png",quality:.8,toBlob:!0},u=n;return t&&Object.keys(n).forEach(function(e){u[e]=t[e]?n[e]:t[e]}),o(e).then(function(s){var c=document.createElement("canvas"),f=c.getContext("2d");return a(s).then(function(e){var t,n,o=e.width,r=e.height;u.compressType===l[1]?n=(t=u.imageSize||o)*r/o:u.compressType===l[2]?t=(n=u.imageSize||r)*o/r:u.compressType===l[3]?r<o?t=(n=u.imageSize||r)*o/r:n=(t=u.imageSize||o)*r/o:(t=o*u.scale,n=r*u.scale);var i=document.createElement("img");i.src=s,c.width=t,c.height=n,f.drawImage(i,0,0,t,n);var a=c.toDataURL(u.imageType,u.quality);return u.toBlob?function(e){try{var t=e.split(","),n=t[0].match(/:(.*?);/)[1];return Promise.resolve(d(t[1],n))}catch(e){return Promise.reject(e)}}(a):a})})},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).ImgAbout={})}(this,function(e){"use strict";"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var t,d=(function(e){var t;t=function(){return function(e,t,n){t=t||"",n=n||512;for(var o=atob(e),r=[],i=0;i<o.length;i+=n){for(var a=o.slice(i,i+n),s=new Array(a.length),c=0;c<a.length;c++)s[c]=a.charCodeAt(c);var f=new Uint8Array(s);r.push(f)}return new Blob(r,{type:t})}},e.exports?(e.exports=t(),e.exports.default=e.exports):window.b64toBlob=t()}(t={exports:{}},t.exports),t.exports);function o(o){return new Promise(function(t,n){try{var e=new FileReader;e.onload=function(e){t(e.target.result)},e.readAsDataURL(o)}catch(e){n(e)}})}function r(r){return new Promise(function(e,t){var n=document.createElement("img"),o=function(){e({width:n.width,height:n.height})};n.onload=o,n.onerror=function(){t(new Error("Image<"+r+"> loaded error"))},n.src=r,n.complete&&o()})}var i=!!document.createElement("canvas").getContext;function a(n){return new Promise(function(e,t){if("string"==typeof n)e(r(n));else if(n instanceof Image)n.naturalWidth?e({width:n.naturalWidth,height:n.naturalHeight}):e(r(n.src));else if(n instanceof FileList||n instanceof File||n instanceof Blob){e(r(o(n[0]||n)))}else t(new Error("The type of param `img` is not matched. It should be an instance of one of the String, Image, File, FileList and Blob"))})}e.canvasSupport=i,e.getNaturalSize=a,e.getSizeOfUrl=r,e.imgCompress=function(e,t){if(!i)return Promise.reject(new Error("Canvas is not supported in your browser"));if(!(e instanceof File||e instanceof Blob))return Promise.reject(new Error("The type of param `imgFile` is not matched It should be an instance of one of the File and Blob"));var l=["scale","fixedWidth","fixedHeight","fixedSize"],n={compressType:l[0],scale:1,imageSize:0,imageType:e.type||"image/png",quality:.8,toBlob:!0},u=n;return t&&Object.keys(n).forEach(function(e){u[e]=t[e]?t[e]:n[e]}),o(e).then(function(s){var c=document.createElement("canvas"),f=c.getContext("2d");return a(s).then(function(e){var t,n,o=e.width,r=e.height;u.compressType===l[1]?n=(t=u.imageSize||o)*r/o:u.compressType===l[2]?t=(n=u.imageSize||r)*o/r:u.compressType===l[3]?r<o?t=(n=u.imageSize||r)*o/r:n=(t=u.imageSize||o)*r/o:(t=o*u.scale,n=r*u.scale);var i=document.createElement("img");i.src=s,c.width=t,c.height=n,f.drawImage(i,0,0,t,n);var a=c.toDataURL(u.imageType,u.quality);return u.toBlob?function(e){try{var t=e.split(","),n=t[0].match(/:(.*?);/)[1];return Promise.resolve(d(t[1],n))}catch(e){return Promise.reject(e)}}(a):a})})},Object.defineProperty(e,"__esModule",{value:!0})}); |
/** | ||
* Bundle of img-about | ||
* Generated: 2019-04-10 | ||
* Version: 2.0.0 | ||
* Version: 2.0.1 | ||
* License: MIT | ||
@@ -6,0 +6,0 @@ * Author: livelybone(2631541504@qq.com) |
{ | ||
"name": "img-about", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "A module for image processing in browser, includes getting naturalSize, zooming, compressing... wrapped by Promise", | ||
@@ -5,0 +5,0 @@ "main": "./lib/umd/index.js", |
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
0
20203