Socket
Socket
Sign inDemoInstall

react-image-file-resizer

Package Overview
Dependencies
0
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.4.1 to 0.4.2

2

build/index.js

@@ -1,1 +0,1 @@

module.exports=(()=>{"use strict";var e={352:(e,t,r)=>{function a(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}r.r(t),r.d(t,{default:()=>o});var n=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,r;return t=e,r=[{key:"changeHeightWidth",value:function(e,t,r,a,n,o){return r>a&&(e=Math.round(e*a/r),r=a),e>t&&(r=Math.round(r*t/e),e=t),n&&r<n&&(e=Math.round(e*n/r),r=n),o&&e<o&&(r=Math.round(r*o/e),e=o),{height:e,width:r}}},{key:"resizeAndRotateImage",value:function(e,t,r,a,n){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"jpeg",i=arguments.length>6&&void 0!==arguments[6]?arguments[6]:100,l=arguments.length>7&&void 0!==arguments[7]?arguments[7]:0,h=i/100,u=document.createElement("canvas"),d=e.width,g=e.height,c=this.changeHeightWidth(g,r,d,t,a,n);!l||90!==l&&270!==l?(u.width=c.width,u.height=c.height):(u.width=c.height,u.height=c.width),d=c.width,g=c.height;var s=u.getContext("2d");return l&&(s.rotate(l*Math.PI/180),90===l?s.translate(0,-u.width):180===l?s.translate(-u.width,-u.height):270===l?s.translate(-u.height,0):0!==l&&360!==l||s.translate(0,0)),s.drawImage(e,0,0,d,g),u.toDataURL("image/".concat(o),h)}},{key:"b64toByteArrays",value:function(e,t){t=t||"image/jpeg";for(var r=atob(e.toString().replace(/^data:image\/(png|jpeg|jpg|webp);base64,/,"")),a=[],n=0;n<r.length;n+=512){for(var o=r.slice(n,n+512),i=new Array(o.length),l=0;l<o.length;l++)i[l]=o.charCodeAt(l);var h=new Uint8Array(i);a.push(h)}return a}},{key:"b64toBlob",value:function(e,t){var r=this.b64toByteArrays(e,t);return new Blob(r,{type:t})}},{key:"b64toFile",value:function(e,t,r){var a=this.b64toByteArrays(e,r);return new File(a,t,{type:r})}},{key:"createResizedImage",value:function(t,r,a,n,o,i,l){var h=arguments.length>7&&void 0!==arguments[7]?arguments[7]:"base64",u=arguments.length>8&&void 0!==arguments[8]?arguments[8]:null,d=arguments.length>9&&void 0!==arguments[9]?arguments[9]:null,g=new FileReader;if(!t)throw Error("File Not Found!");if(t.type&&!t.type.includes("image"))throw Error("File Is NOT Image!");g.readAsDataURL(t),g.onload=function(){var t=new Image;t.src=g.result,t.onload=function(){var g=e.resizeAndRotateImage(t,r,a,u,d,n,o,i),c="image/".concat(n);switch(h){case"blob":var s=e.b64toBlob(g,c);l(s);break;case"base64":l(g);break;case"file":var f=e.b64toFile(g,f.name,c);l(f);break;default:l(g)}}},g.onerror=function(e){throw Error(e)}}}],null&&a(t.prototype,null),r&&a(t,r),e}();const o={imageFileResizer:function(e,t,r,a,o,i,l,h,u,d){return n.createResizedImage(e,t,r,a,o,i,l,h,u,d)}}}},t={};function r(a){if(t[a])return t[a].exports;var n=t[a]={exports:{}};return e[a](n,n.exports,r),n.exports}return r.d=(e,t)=>{for(var a in t)r.o(t,a)&&!r.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r(352)})();
module.exports=(()=>{"use strict";var e={352:(e,t,r)=>{function a(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}r.r(t),r.d(t,{default:()=>o});var n=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,r;return t=e,r=[{key:"changeHeightWidth",value:function(e,t,r,a,n,o){return r>a&&(e=Math.round(e*a/r),r=a),e>t&&(r=Math.round(r*t/e),e=t),n&&r<n&&(e=Math.round(e*n/r),r=n),o&&e<o&&(r=Math.round(r*o/e),e=o),{height:e,width:r}}},{key:"resizeAndRotateImage",value:function(e,t,r,a,n){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"jpeg",i=arguments.length>6&&void 0!==arguments[6]?arguments[6]:100,l=arguments.length>7&&void 0!==arguments[7]?arguments[7]:0,h=i/100,u=document.createElement("canvas"),d=e.width,g=e.height,c=this.changeHeightWidth(g,r,d,t,a,n);!l||90!==l&&270!==l?(u.width=c.width,u.height=c.height):(u.width=c.height,u.height=c.width),d=c.width,g=c.height;var s=u.getContext("2d");return l&&(s.rotate(l*Math.PI/180),90===l?s.translate(0,-u.width):180===l?s.translate(-u.width,-u.height):270===l?s.translate(-u.height,0):0!==l&&360!==l||s.translate(0,0)),s.drawImage(e,0,0,d,g),u.toDataURL("image/".concat(o),h)}},{key:"b64toByteArrays",value:function(e,t){t=t||"image/jpeg";for(var r=atob(e.toString().replace(/^data:image\/(png|jpeg|jpg|webp);base64,/,"")),a=[],n=0;n<r.length;n+=512){for(var o=r.slice(n,n+512),i=new Array(o.length),l=0;l<o.length;l++)i[l]=o.charCodeAt(l);var h=new Uint8Array(i);a.push(h)}return a}},{key:"b64toBlob",value:function(e,t){var r=this.b64toByteArrays(e,t);return new Blob(r,{type:t})}},{key:"b64toFile",value:function(e,t,r){var a=this.b64toByteArrays(e,r);return new File(a,t,{type:r})}},{key:"createResizedImage",value:function(t,r,a,n,o,i,l){var h=arguments.length>7&&void 0!==arguments[7]?arguments[7]:"base64",u=arguments.length>8&&void 0!==arguments[8]?arguments[8]:null,d=arguments.length>9&&void 0!==arguments[9]?arguments[9]:null,g=new FileReader;if(!t)throw Error("File Not Found!");if(t.type&&!t.type.includes("image"))throw Error("File Is NOT Image!");g.readAsDataURL(t),g.onload=function(){var c=new Image;c.src=g.result,c.onload=function(){var g=e.resizeAndRotateImage(c,r,a,u,d,n,o,i),s="image/".concat(n);switch(h){case"blob":var f=e.b64toBlob(g,s);l(f);break;case"base64":l(g);break;case"file":var v=e.b64toFile(g,t.name,s);l(v);break;default:l(g)}}},g.onerror=function(e){throw Error(e)}}}],null&&a(t.prototype,null),r&&a(t,r),e}();const o={imageFileResizer:function(e,t,r,a,o,i,l,h,u,d){return n.createResizedImage(e,t,r,a,o,i,l,h,u,d)}}}},t={};function r(a){if(t[a])return t[a].exports;var n=t[a]={exports:{}};return e[a](n,n.exports,r),n.exports}return r.d=(e,t)=>{for(var a in t)r.o(t,a)&&!r.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r(352)})();
{
"name": "react-image-file-resizer",
"version": "0.4.1",
"version": "0.4.2",
"description": "React module that can rescaled local images. You can change image's width, height, format, rotation and quality. It returns resized image's new base64 URI or Blob. The URI can be used as the source of an <Image> component.",

@@ -59,4 +59,3 @@ "main": "build/index.js",

"webpack-cli": "^3.3.12"
},
"dependencies": {}
}
}
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc