New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

browser-image-resizer

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browser-image-resizer - npm Package Compare versions

Comparing version 2.3.3 to 2.4.0

1

dist/index.d.ts

@@ -5,3 +5,2 @@ export interface Config {

maxHeight?: number
autoRotate?: boolean
debug?: boolean

@@ -8,0 +7,0 @@ mimeType?: string

7

package.json
{
"name": "browser-image-resizer",
"version": "2.3.3",
"version": "2.4.0",
"description": "A browser-based utility to downscale and resize images using <canvas>",

@@ -20,6 +20,3 @@ "main": "dist/index.js",

},
"repository": "https://github.com/ericnograles/browser-image-resizer.git",
"dependencies": {
"exifreader": "^4.5.1"
}
"repository": "https://github.com/ericnograles/browser-image-resizer.git"
}
# browser-image-resizer
A tiny (~7kb ) browser-based library to downscale and/or resize images using `<canvas>`.
## Introduction
This library allows for cross-browser image downscaling and resizing utilizing `<canvas>`. The code was part of Ross Turner's [HTML5-ImageUploader](https://github.com/rossturner/HTML5-ImageUploader). Note that this is meant to be a browser-only utility and will not work in Node.js.
The code was part of Ross Turner's [HTML5-ImageUploader](https://github.com/rossturner/HTML5-ImageUploader). Note that this is meant to be a browser-only utility and will not work in Node.js.

@@ -38,3 +40,2 @@ ## Demo

maxHeight: 600,
autoRotate: true,
debug: true

@@ -108,3 +109,2 @@ };

maxHeight: 600,
autoRotate: true,
debug: true

@@ -111,0 +111,0 @@ };

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

import ExifReader from 'exifreader';
import { initializeOrGetImg } from './browser_operations';

@@ -26,27 +25,2 @@ import { scaleImage } from './scaling_operations';

let scaleImageOptions = { img, config }
if (config.autoRotate) {
if (config.debug)
console.log(
'browser-image-resizer: detecting image orientation...'
);
let Orientation = {};
try {
const Result = ExifReader.load(file);
Orientation = Result.Orientation || {};
} catch (err) {
console.error('browser-image-resizer: Error getting orientation')
console.error(err)
}
if (config.debug) {
console.log(
'browser-image-resizer: image orientation from EXIF tag = ' +
Orientation
);
}
scaleImageOptions.orientation = Orientation.value
} else if (config.debug) {
console.log(
'browser-image-resizer: ignoring EXIF orientation tag because autoRotate is false...'
);
}
try {

@@ -53,0 +27,0 @@ let blob = scaleImage(scaleImageOptions);

@@ -47,48 +47,2 @@ import { dataURIToBlob } from './data_operations';

function exifApplied(canvas, ctx, orientation, img) {
let width = canvas.width;
let styleWidth = canvas.style.width;
let height = canvas.height;
let styleHeight = canvas.style.height;
if (orientation > 4) {
canvas.width = height;
canvas.style.width = styleHeight;
canvas.height = width;
canvas.style.height = styleWidth;
}
switch (orientation) {
case 2:
ctx.translate(width, 0);
ctx.scale(-1, 1);
break;
case 3:
ctx.translate(width, height);
ctx.rotate(Math.PI);
break;
case 4:
ctx.translate(0, height);
ctx.scale(1, -1);
break;
case 5:
ctx.rotate(0.5 * Math.PI);
ctx.scale(1, -1);
break;
case 6:
ctx.rotate(0.5 * Math.PI);
ctx.translate(0, -height);
break;
case 7:
ctx.rotate(0.5 * Math.PI);
ctx.translate(width, -height);
ctx.scale(-1, 1);
break;
case 8:
ctx.rotate(-0.5 * Math.PI);
ctx.translate(-width, 0);
break;
}
ctx.drawImage(img, 0, 0);
ctx.restore();
}
function scaleCanvasWithAlgorithm(canvas, config) {

@@ -221,3 +175,4 @@ let scaledCanvas = document.createElement('canvas');

// EXIF
exifApplied(canvas, ctx, orientation, img);
ctx.drawImage(img, 0, 0);
ctx.restore();

@@ -224,0 +179,0 @@ let maxWidth = findMaxWidth(config, canvas);

@@ -12,3 +12,3 @@ import React, { Component } from "react";

onChange = async event => {
let image = await readAndCompressImage(event.target.files[0], { mimeType: 'image/jpeg'});
let image = await readAndCompressImage(event.target.files[0], { mimeType: 'image/jpeg', debug: true });
let base64Image = await this.convertToBase64(image);

@@ -15,0 +15,0 @@ this.setState({ image: base64Image });

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc