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.0 to 0.4.1

2

build/index.js

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

module.exports=(()=>{"use strict";var e={352:(e,t,r)=>{function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}r.r(t),r.d(t,{default:()=>o});var a=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,n,a,o){return r>n&&(e=Math.round(e*n/r),r=n),e>t&&(r=Math.round(r*t/e),e=t),a&&r<a&&(e=Math.round(e*a/r),r=a),o&&e<o&&(r=Math.round(r*o/e),e=o),{height:e,width:r}}},{key:"resizeAndRotateImage",value:function(e,t,r,n,a){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"),g=e.width,d=e.height,c=this.changeHeightWidth(d,r,g,t,n,a);!l||90!==l&&270!==l?(u.width=c.width,u.height=c.height):(u.width=c.height,u.height=c.width),g=c.width,d=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,g,d),u.toDataURL("image/".concat(o),h)}},{key:"b64toBlob",value:function(e,t){t=t||"image/jpeg";for(var r=atob(e.toString().replace(/^data:image\/(png|jpeg|jpg|webp);base64,/,"")),n=[],a=0;a<r.length;a+=512){for(var o=r.slice(a,a+512),i=new Array(o.length),l=0;l<o.length;l++)i[l]=o.charCodeAt(l);var h=new Uint8Array(i);n.push(h)}return new Blob(n,{type:t})}},{key:"createResizedImage",value:function(t,r,n,a,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,g=arguments.length>9&&void 0!==arguments[9]?arguments[9]:null,d=null,c=new FileReader;if(!t)throw Error("File Not Found!");if(t.type&&!t.type.includes("image"))throw Error("File Is NOT Image!");c.readAsDataURL(t),c.onload=function(){var t=new Image;t.src=c.result,t.onload=function(){var c=e.resizeAndRotateImage(t,r,n,u,g,a,o,i);d=e.b64toBlob(c,"image/".concat(a)),l("blob"===h?d:c)}},c.onerror=function(e){throw Error(e)}}}],null&&n(t.prototype,null),r&&n(t,r),e}();const o={imageFileResizer:function(e,t,r,n,o,i,l,h,u,g){return a.createResizedImage(e,t,r,n,o,i,l,h,u,g)}}}},t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={exports:{}};return e[n](a,a.exports,r),a.exports}return r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},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 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)})();

@@ -24,2 +24,3 @@ declare module "react-image-file-resizer" {

static b64toBlob(b64Data: string, contentType: string): Blob;
static b64toFile(b64Data: string, fileName: string, contentType: string): File;

@@ -34,3 +35,3 @@ static createResizedImage(

responseUriFunc: (
value: string | Blob | ProgressEvent<FileReader>
value: string | Blob | File | ProgressEvent<FileReader>
) => void,

@@ -37,0 +38,0 @@ outputType?: string,

{
"name": "react-image-file-resizer",
"version": "0.4.0",
"version": "0.4.1",
"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-6-orange.svg?style=flat-square)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-7-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

@@ -131,7 +131,7 @@

`maxHeight` | New image max height (ratio is preserved) | `number` | Yes
`compressFormat` | Can be either JPEG, PNG or WEBP. | `string` | Yes
`compressFormat` | Can be either **JPEG**, **PNG** or **WEBP**. | `string` | Yes
`quality` | A number between 0 and 100. Used for the JPEG compression.(if no compress is needed, just set it to 100) | `number` | Yes
`rotation` | Degree of clockwise rotation to apply to the image. Rotation is limited to multiples of 90 degrees.(if no rotation is needed, just set it to 0) (0, 90, 180, 270, 360) | `number` | Yes
`responseUriFunc` | Callback function of URI. Returns URI of resized image's base64 format. ex: `uri => {console.log(uri)});` | `function` | Yes
`outputType` | Can be either base64 or blob.(Default type is base64) | `string` | No
`outputType` | Can be either **base64**, **blob** or **file**.(Default type is base64) | `string` | No
`minWidth` | New image min width (ratio is preserved, defaults to null) | `number` | No

@@ -152,8 +152,9 @@ `minHeight` | New image min height (ratio is preserved, defaults to null) | `number` | No

<tr>
<td align="center"><a href="https://github.com/AhmadMaleki"><img src="https://avatars2.githubusercontent.com/u/26637638?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ahmad Maleki</b></sub></a><br /><a href="https://github.com/Onur Zorluer/react-image-file-resizer/commits?author=AhmadMaleki" title="Code">💻</a> <a href="#maintenance-AhmadMaleki" title="Maintenance">🚧</a></td>
<td align="center"><a href="http://www.vysnovsky.sk/"><img src="https://avatars1.githubusercontent.com/u/5657185?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Martin Vyšňovský</b></sub></a><br /><a href="https://github.com/Onur Zorluer/react-image-file-resizer/commits?author=martinvysnovsky" title="Code">💻</a> <a href="#maintenance-martinvysnovsky" title="Maintenance">🚧</a></td>
<td align="center"><a href="https://github.com/nadunc"><img src="https://avatars2.githubusercontent.com/u/22863180?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nadun Chamikara</b></sub></a><br /><a href="https://github.com/Onur Zorluer/react-image-file-resizer/commits?author=nadunc" title="Code">💻</a> <a href="#maintenance-nadunc" title="Maintenance">🚧</a></td>
<td align="center"><a href="https://shubhamzanwar.github.io/"><img src="https://avatars0.githubusercontent.com/u/15626155?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Shubham Zanwar</b></sub></a><br /><a href="https://github.com/Onur Zorluer/react-image-file-resizer/commits?author=shubhamzanwar" title="Documentation">📖</a></td>
<td align="center"><a href="https://www.linkedin.com/in/onderonur/"><img src="https://avatars0.githubusercontent.com/u/50423574?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Onur Önder</b></sub></a><br /><a href="https://github.com/Onur Zorluer/react-image-file-resizer/commits?author=onderonur" title="Code">💻</a> <a href="#maintenance-onderonur" title="Maintenance">🚧</a></td>
<td align="center"><a href="https://emreaybey.com/"><img src="https://avatars1.githubusercontent.com/u/45988990?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Yunus Emre</b></sub></a><br /><a href="https://github.com/Onur Zorluer/react-image-file-resizer/commits?author=YemreAybey" title="Code">💻</a> <a href="#maintenance-YemreAybey" title="Maintenance">🚧</a></td>
<td align="center"><a href="https://github.com/AhmadMaleki"><img src="https://avatars2.githubusercontent.com/u/26637638?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ahmad Maleki</b></sub></a><br /><a href="https://github.com/onurzorluer/react-image-file-resizer/commits?author=AhmadMaleki" title="Code">💻</a> <a href="#maintenance-AhmadMaleki" title="Maintenance">🚧</a></td>
<td align="center"><a href="http://www.vysnovsky.sk/"><img src="https://avatars1.githubusercontent.com/u/5657185?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Martin Vyšňovský</b></sub></a><br /><a href="https://github.com/onurzorluer/react-image-file-resizer/commits?author=martinvysnovsky" title="Code">💻</a> <a href="#maintenance-martinvysnovsky" title="Maintenance">🚧</a></td>
<td align="center"><a href="https://github.com/nadunc"><img src="https://avatars2.githubusercontent.com/u/22863180?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nadun Chamikara</b></sub></a><br /><a href="https://github.com/onurzorluer/react-image-file-resizer/commits?author=nadunc" title="Code">💻</a> <a href="#maintenance-nadunc" title="Maintenance">🚧</a></td>
<td align="center"><a href="https://shubhamzanwar.github.io/"><img src="https://avatars0.githubusercontent.com/u/15626155?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Shubham Zanwar</b></sub></a><br /><a href="https://github.com/onurzorluer/react-image-file-resizer/commits?author=shubhamzanwar" title="Documentation">📖</a></td>
<td align="center"><a href="https://www.linkedin.com/in/onderonur/"><img src="https://avatars0.githubusercontent.com/u/50423574?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Onur Önder</b></sub></a><br /><a href="https://github.com/onurzorluer/react-image-file-resizer/commits?author=onderonur" title="Code">💻</a> <a href="#maintenance-onderonur" title="Maintenance">🚧</a></td>
<td align="center"><a href="https://emreaybey.com/"><img src="https://avatars1.githubusercontent.com/u/45988990?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Yunus Emre</b></sub></a><br /><a href="https://github.com/onurzorluer/react-image-file-resizer/commits?author=YemreAybey" title="Code">💻</a> <a href="#maintenance-YemreAybey" title="Maintenance">🚧</a></td>
<td align="center"><a href="https://www.linkedin.com/in/velascojuan/"><img src="https://avatars.githubusercontent.com/u/4591845?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Juan</b></sub></a><br /><a href="https://github.com/onurzorluer/react-image-file-resizer/commits?author=OverStruck" title="Code">💻</a> <a href="#maintenance-OverStruck" title="Maintenance">🚧</a></td>
</tr>

@@ -164,2 +165,3 @@ </table>

<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->

@@ -166,0 +168,0 @@

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