exif-rotate-js
Advanced tools
Comparing version 1.0.3 to 1.1.0
@@ -0,1 +1,13 @@ | ||
## v1.1.0 | ||
### Feature | ||
- Update logic of getSize(). When masSize is higher than image size, use default size [#114](https://github.com/hanagejet/exif-rotate-js/pull/114) | ||
## v1.0.3 | ||
### Feature | ||
- add prepublish [#57](https://github.com/hanagejet/exif-rotate-js/pull/57) | ||
## v1.0.2 | ||
@@ -2,0 +14,0 @@ |
@@ -13,6 +13,8 @@ "use strict"; | ||
function getSize(width, height, maxSize = options_1.defaultOptions.maxSize) { | ||
const parseWidth = maxSize < width ? maxSize : width; | ||
const parseHeight = maxSize < height ? maxSize : height; | ||
if (width > height) { | ||
return { | ||
width: maxSize, | ||
height: height * (maxSize / width), | ||
width: parseWidth, | ||
height: height * (parseWidth / width), | ||
}; | ||
@@ -22,9 +24,9 @@ } | ||
return { | ||
width: width * (maxSize / height), | ||
height: maxSize, | ||
width: width * (parseHeight / height), | ||
height: parseHeight, | ||
}; | ||
} | ||
return { | ||
width: maxSize, | ||
height: maxSize, | ||
width: parseWidth, | ||
height: parseHeight, | ||
}; | ||
@@ -31,0 +33,0 @@ } |
{ | ||
"name": "exif-rotate-js", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"description": "", | ||
@@ -17,15 +17,15 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@babel/preset-env": "7.5.5", | ||
"@babel/preset-typescript": "7.3.3", | ||
"@types/jest": "24.0.18", | ||
"@typescript-eslint/eslint-plugin": "2.0.0", | ||
"@typescript-eslint/parser": "2.0.0", | ||
"@babel/preset-env": "7.8.0", | ||
"@babel/preset-typescript": "7.8.0", | ||
"@types/jest": "24.0.25", | ||
"@typescript-eslint/eslint-plugin": "2.15.0", | ||
"@typescript-eslint/parser": "2.15.0", | ||
"babel-jest": "24.9.0", | ||
"eslint": "6.2.1", | ||
"eslint-config-prettier": "6.1.0", | ||
"eslint-plugin-prettier": "3.1.0", | ||
"eslint": "6.8.0", | ||
"eslint-config-prettier": "6.9.0", | ||
"eslint-plugin-prettier": "3.1.2", | ||
"jest": "24.9.0", | ||
"prettier": "1.18.2", | ||
"ts-jest": "24.0.2", | ||
"typescript": "3.5.3" | ||
"prettier": "1.19.1", | ||
"ts-jest": "24.3.0", | ||
"typescript": "3.7.4" | ||
}, | ||
@@ -32,0 +32,0 @@ "repository": { |
@@ -5,7 +5,19 @@ import { getSize } from '../getImages'; | ||
const MAX_SIZE = 200; | ||
const GREATERE_WIDTH = { | ||
const GREATER_MAXSIZE_WIDTH = { | ||
width: 3000, | ||
height: 10, | ||
}; | ||
const GREATER_MAXSIZE_HEIGHT = { | ||
width: 10, | ||
height: 3000, | ||
}; | ||
const GREATER_MAXSIZE_SAME_WIDTH_HEIGHT = { | ||
width: 3000, | ||
height: 3000, | ||
}; | ||
const GREATER_WIDTH = { | ||
width: 100, | ||
height: 10, | ||
}; | ||
const GREATERE_HEIGHT = { | ||
const GREATER_HEIGHT = { | ||
width: 10, | ||
@@ -21,3 +33,3 @@ height: 100, | ||
it('Should be return MAX_SIZE of width', () => { | ||
const { width, height } = GREATERE_WIDTH; | ||
const { width, height } = GREATER_MAXSIZE_WIDTH; | ||
expect(getSize(width, height, MAX_SIZE)).toEqual({ | ||
@@ -30,3 +42,3 @@ width: MAX_SIZE, | ||
it('Should be return MAX_SIZE of height', () => { | ||
const { width, height } = GREATERE_HEIGHT; | ||
const { width, height } = GREATER_MAXSIZE_HEIGHT; | ||
expect(getSize(width, height, MAX_SIZE)).toEqual({ | ||
@@ -38,5 +50,29 @@ width: width * (MAX_SIZE / height), | ||
it('Should be return MAX_SIZE of width and height', () => { | ||
it('Should be return default size, when width is lower size than MAX_SIZE', () => { | ||
const { width, height } = GREATER_WIDTH; | ||
expect(getSize(width, height, MAX_SIZE)).toEqual({ | ||
width, | ||
height, | ||
}); | ||
}); | ||
it('Should be return default size, when height is lower size than MAX_SIZE', () => { | ||
const { width, height } = GREATER_HEIGHT; | ||
expect(getSize(width, height, MAX_SIZE)).toEqual({ | ||
width, | ||
height, | ||
}); | ||
}); | ||
it('Should be return of default size, when width and height are lower size than MAX_SIZE', () => { | ||
const { width, height } = SAME_WIDTH_HEIGHT; | ||
expect(getSize(width, height, MAX_SIZE)).toEqual({ | ||
width, | ||
height, | ||
}); | ||
}); | ||
it('Should be return MAX_SIZE of width and height', () => { | ||
const { width, height } = GREATER_MAXSIZE_SAME_WIDTH_HEIGHT; | ||
expect(getSize(width, height, MAX_SIZE)).toEqual({ | ||
width: MAX_SIZE, | ||
@@ -47,4 +83,12 @@ height: MAX_SIZE, | ||
it('Should be return width, height without argument of MAX_SIZE', () => { | ||
const { width, height } = GREATERE_WIDTH; | ||
it('Should be return default width and height without argument of MAX_SIZE', () => { | ||
const { width, height } = GREATER_WIDTH; | ||
expect(getSize(width, height)).toEqual({ | ||
width, | ||
height, | ||
}); | ||
}); | ||
it('Should be return default MAX_SIZE without argument of MAX_SIZE', () => { | ||
const { width, height } = GREATER_MAXSIZE_WIDTH; | ||
const { maxSize } = defaultOptions; | ||
@@ -51,0 +95,0 @@ expect(getSize(width, height)).toEqual({ |
@@ -30,6 +30,8 @@ import * as EXIF from 'exif-js'; | ||
) { | ||
const parseWidth = maxSize < width ? maxSize : width; | ||
const parseHeight = maxSize < height ? maxSize : height; | ||
if (width > height) { | ||
return { | ||
width: maxSize, | ||
height: height * (maxSize / width), | ||
width: parseWidth, | ||
height: height * (parseWidth / width), | ||
}; | ||
@@ -39,9 +41,9 @@ } | ||
return { | ||
width: width * (maxSize / height), | ||
height: maxSize, | ||
width: width * (parseHeight / height), | ||
height: parseHeight, | ||
}; | ||
} | ||
return { | ||
width: maxSize, | ||
height: maxSize, | ||
width: parseWidth, | ||
height: parseHeight, | ||
}; | ||
@@ -48,0 +50,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21646
639