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.7 to 0.4.8

2

build/index.js

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

(()=>{"use strict";var e={d:(t,a)=>{for(var r in a)e.o(a,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:a[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function a(e,t){for(var a=0;a<t.length;a++){var r=t[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}e.r(t),e.d(t,{default:()=>n});var r=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,a,r,n,o){return a>r&&(e=Math.round(e*r/a),a=r),e>t&&(a=Math.round(a*t/e),e=t),n&&a<n&&(e=Math.round(e*n/a),a=n),o&&e<o&&(a=Math.round(a*o/e),e=o),{height:e,width:a}}},{key:"resizeAndRotateImage",value:function(e,t,a,r,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,g=document.createElement("canvas"),u=e.width,d=e.height,c=this.changeHeightWidth(d,a,u,t,r,n);!l||90!==l&&270!==l?(g.width=c.width,g.height=c.height):(g.width=c.height,g.height=c.width),u=c.width,d=c.height;var s=g.getContext("2d");return s.fillStyle="rgba(0, 0, 0, 0)",s.fillRect(0,0,u,d),l&&(s.rotate(l*Math.PI/180),90===l?s.translate(0,-g.width):180===l?s.translate(-g.width,-g.height):270===l?s.translate(-g.height,0):0!==l&&360!==l||s.translate(0,0)),s.drawImage(e,0,0,u,d),g.toDataURL("image/".concat(o),h)}},{key:"b64toByteArrays",value:function(e,t){t=t||"image/jpeg";for(var a=atob(e.toString().replace(/^data:image\/(png|jpeg|jpg|webp);base64,/,"")),r=[],n=0;n<a.length;n+=512){for(var o=a.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);r.push(h)}return r}},{key:"b64toBlob",value:function(e,t){var a=this.b64toByteArrays(e,t);return new Blob(a,{type:t,lastModified:new Date})}},{key:"b64toFile",value:function(e,t,a){var r=this.b64toByteArrays(e,a);return new File(r,t,{type:a,lastModified:new Date})}},{key:"createResizedImage",value:function(t,a,r,n,o,i,l){var h=arguments.length>7&&void 0!==arguments[7]?arguments[7]:"base64",g=arguments.length>8&&void 0!==arguments[8]?arguments[8]:null,u=arguments.length>9&&void 0!==arguments[9]?arguments[9]:null,d=new FileReader;if(!t)throw Error("File Not Found!");if(t.type&&!t.type.includes("image"))throw Error("File Is NOT Image!");d.readAsDataURL(t),d.onload=function(){var c=new Image;c.src=d.result,c.onload=function(){var d=e.resizeAndRotateImage(c,a,r,g,u,n,o,i),s="image/".concat(n);switch(h){case"blob":var f=e.b64toBlob(d,s);l(f);break;case"base64":l(d);break;case"file":var b=t.name.toString().replace(/(png|jpeg|jpg|webp)$/i,"").concat(n.toString()),v=e.b64toFile(d,b,s);l(v);break;default:l(d)}}},d.onerror=function(e){throw Error(e)}}}],null&&a(t.prototype,null),r&&a(t,r),e}();const n={imageFileResizer:function(e,t,a,n,o,i,l,h,g,u){return r.createResizedImage(e,t,a,n,o,i,l,h,g,u)}};module.exports=t})();
(()=>{"use strict";var e={d:(t,a)=>{for(var r in a)e.o(a,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:a[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function a(e,t){for(var a=0;a<t.length;a++){var r=t[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}e.r(t),e.d(t,{default:()=>n});var r=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,a,r,n,i){return a>r&&(e=Math.round(e*r/a),a=r),e>t&&(a=Math.round(a*t/e),e=t),n&&a<n&&(e=Math.round(e*n/a),a=n),i&&e<i&&(a=Math.round(a*i/e),e=i),{height:e,width:a}}},{key:"resizeAndRotateImage",value:function(e,t,a,r,n){var i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"jpeg",o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:100,l=arguments.length>7&&void 0!==arguments[7]?arguments[7]:0,h=o/100,g=document.createElement("canvas"),u=e.width,d=e.height,c=this.changeHeightWidth(d,a,u,t,r,n);!l||90!==l&&270!==l?(g.width=c.width,g.height=c.height):(g.width=c.height,g.height=c.width),u=c.width,d=c.height;var s=g.getContext("2d");return s.fillStyle="rgba(0, 0, 0, 0)",s.fillRect(0,0,u,d),s.imageSmoothingEnabled&&s.imageSmoothingQuality&&(s.imageSmoothingQuality="high"),l&&(s.rotate(l*Math.PI/180),90===l?s.translate(0,-g.width):180===l?s.translate(-g.width,-g.height):270===l?s.translate(-g.height,0):0!==l&&360!==l||s.translate(0,0)),s.drawImage(e,0,0,u,d),g.toDataURL("image/".concat(i),h)}},{key:"b64toByteArrays",value:function(e,t){t=t||"image/jpeg";for(var a=atob(e.toString().replace(/^data:image\/(png|jpeg|jpg|webp);base64,/,"")),r=[],n=0;n<a.length;n+=512){for(var i=a.slice(n,n+512),o=new Array(i.length),l=0;l<i.length;l++)o[l]=i.charCodeAt(l);var h=new Uint8Array(o);r.push(h)}return r}},{key:"b64toBlob",value:function(e,t){var a=this.b64toByteArrays(e,t);return new Blob(a,{type:t,lastModified:new Date})}},{key:"b64toFile",value:function(e,t,a){var r=this.b64toByteArrays(e,a);return new File(r,t,{type:a,lastModified:new Date})}},{key:"createResizedImage",value:function(t,a,r,n,i,o,l){var h=arguments.length>7&&void 0!==arguments[7]?arguments[7]:"base64",g=arguments.length>8&&void 0!==arguments[8]?arguments[8]:null,u=arguments.length>9&&void 0!==arguments[9]?arguments[9]:null,d=new FileReader;if(!t)throw Error("File Not Found!");if(t.type&&!t.type.includes("image"))throw Error("File Is NOT Image!");d.readAsDataURL(t),d.onload=function(){var c=new Image;c.src=d.result,c.onload=function(){var d=e.resizeAndRotateImage(c,a,r,g,u,n,i,o),s="image/".concat(n);switch(h){case"blob":var f=e.b64toBlob(d,s);l(f);break;case"base64":l(d);break;case"file":var b=t.name.toString().replace(/(png|jpeg|jpg|webp)$/i,"").concat(n.toString()),v=e.b64toFile(d,b,s);l(v);break;default:l(d)}}},d.onerror=function(e){throw Error(e)}}}],null&&a(t.prototype,null),r&&a(t,r),e}();const n={imageFileResizer:function(e,t,a,n,i,o,l,h,g,u){return r.createResizedImage(e,t,a,n,i,o,l,h,g,u)}};module.exports=t})();
{
"name": "react-image-file-resizer",
"version": "0.4.7",
"version": "0.4.8",
"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.",

@@ -5,0 +5,0 @@ "main": "build/index.js",

# React Image File Resizer
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-9-orange.svg?style=flat-square)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-10-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

@@ -178,2 +178,3 @@

<td align="center"><a href="https://github.com/andresriveratoro"><img src="https://avatars.githubusercontent.com/u/36863582?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Andres Rivera</b></sub></a><br /><a href="https://github.com/onurzorluer/react-image-file-resizer/commits?author=andresriveratoro" title="Code">💻</a> <a href="#maintenance-andresriveratoro" title="Maintenance">🚧</a></td>
<td align="center"><a href="https://github.com/mmmulani"><img src="https://avatars.githubusercontent.com/u/192928?v=4?s=100" width="100px;" alt=""/><br /><sub><b>mmmulani</b></sub></a><br /><a href="https://github.com/onurzorluer/react-image-file-resizer/commits?author=mmmulani" title="Code">💻</a> <a href="#maintenance-mmmulani" title="Maintenance">🚧</a></td>
</tr>

@@ -180,0 +181,0 @@ </table>

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