@jimp/plugin-rotate
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -0,1 +1,13 @@ | ||
# v1.1.2 (Mon Sep 02 2024) | ||
#### 🐛 Bug Fix | ||
- Rotate short circuit [#1317](https://github.com/jimp-dev/jimp/pull/1317) ([@hipstersmoothie](https://github.com/hipstersmoothie)) | ||
#### Authors: 1 | ||
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) | ||
--- | ||
# v1.1.0 (Sun Sep 01 2024) | ||
@@ -2,0 +14,0 @@ |
@@ -35,7 +35,2 @@ "use strict"; | ||
} | ||
deg %= 360; | ||
if (Math.abs(deg) === 0) { | ||
// no rotation for 0, 360, -360, 720, -720, ... | ||
return; | ||
} | ||
const w = image.bitmap.width; | ||
@@ -107,3 +102,2 @@ const h = image.bitmap.height; | ||
function advancedRotate(image, deg, mode) { | ||
deg %= 360; | ||
const rad = (deg * Math.PI) / 180; | ||
@@ -188,3 +182,9 @@ const cosine = Math.cos(rad); | ||
const parsed = RotateOptionsSchema.parse(options); | ||
const { deg, mode = true } = typeof parsed === "number" ? { deg: parsed } : parsed; | ||
let { deg, mode = true } = typeof parsed === "number" ? { deg: parsed } : parsed; | ||
// No need to do extra rotation | ||
deg %= 360; | ||
// no rotation for 0, 360, -360, 720, -720, ... | ||
if (deg % 360 === 0) { | ||
return image; | ||
} | ||
// use matrixRotate if the angle is a multiple of 90 degrees (eg: 180 or -90) and resize is allowed or not needed. | ||
@@ -191,0 +191,0 @@ const matrixRotateAllowed = deg % 90 === 0 && |
@@ -32,7 +32,2 @@ import { ResizeStrategy, methods as resizeMethods } from "@jimp/plugin-resize"; | ||
} | ||
deg %= 360; | ||
if (Math.abs(deg) === 0) { | ||
// no rotation for 0, 360, -360, 720, -720, ... | ||
return; | ||
} | ||
const w = image.bitmap.width; | ||
@@ -104,3 +99,2 @@ const h = image.bitmap.height; | ||
function advancedRotate(image, deg, mode) { | ||
deg %= 360; | ||
const rad = (deg * Math.PI) / 180; | ||
@@ -185,3 +179,9 @@ const cosine = Math.cos(rad); | ||
const parsed = RotateOptionsSchema.parse(options); | ||
const { deg, mode = true } = typeof parsed === "number" ? { deg: parsed } : parsed; | ||
let { deg, mode = true } = typeof parsed === "number" ? { deg: parsed } : parsed; | ||
// No need to do extra rotation | ||
deg %= 360; | ||
// no rotation for 0, 360, -360, 720, -720, ... | ||
if (deg % 360 === 0) { | ||
return image; | ||
} | ||
// use matrixRotate if the angle is a multiple of 90 degrees (eg: 180 or -90) and resize is allowed or not needed. | ||
@@ -188,0 +188,0 @@ const matrixRotateAllowed = deg % 90 === 0 && |
{ | ||
"name": "@jimp/plugin-rotate", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"repository": "jimp-dev/jimp", | ||
@@ -16,15 +16,15 @@ "scripts": { | ||
"dependencies": { | ||
"@jimp/core": "1.1.1", | ||
"@jimp/plugin-crop": "1.1.1", | ||
"@jimp/plugin-resize": "1.1.1", | ||
"@jimp/types": "1.1.1", | ||
"@jimp/utils": "1.1.1", | ||
"@jimp/core": "1.1.2", | ||
"@jimp/plugin-crop": "1.1.2", | ||
"@jimp/plugin-resize": "1.1.2", | ||
"@jimp/types": "1.1.2", | ||
"@jimp/utils": "1.1.2", | ||
"zod": "^3.22.4" | ||
}, | ||
"devDependencies": { | ||
"@jimp/config-eslint": "1.1.1", | ||
"@jimp/config-typescript": "1.1.1", | ||
"@jimp/config-vitest": "1.1.1", | ||
"@jimp/config-eslint": "1.1.2", | ||
"@jimp/config-typescript": "1.1.2", | ||
"@jimp/config-vitest": "1.1.2", | ||
"@jimp/core": "workspace:*", | ||
"@jimp/test-utils": "1.1.1", | ||
"@jimp/test-utils": "1.1.2", | ||
"@types/node": "^20.12.5", | ||
@@ -68,3 +68,3 @@ "@vitest/browser": "^1.4.0", | ||
"module": "./dist/esm/index.js", | ||
"gitHead": "310b6ef10aaddedf85fb326fcc793d29f23c36d8" | ||
"gitHead": "ba9de4df25a2f0e41f11a68c7aa50181a52115cb" | ||
} |
@@ -39,9 +39,2 @@ import { ResizeStrategy, methods as resizeMethods } from "@jimp/plugin-resize"; | ||
deg %= 360; | ||
if (Math.abs(deg) === 0) { | ||
// no rotation for 0, 360, -360, 720, -720, ... | ||
return; | ||
} | ||
const w = image.bitmap.width; | ||
@@ -52,2 +45,3 @@ const h = image.bitmap.height; | ||
let angle; | ||
switch (deg) { | ||
@@ -131,3 +125,2 @@ // 90 degree & -270 degree are same | ||
) { | ||
deg %= 360; | ||
const rad = (deg * Math.PI) / 180; | ||
@@ -241,4 +234,13 @@ const cosine = Math.cos(rad); | ||
const parsed = RotateOptionsSchema.parse(options); | ||
const { deg, mode = true } = | ||
let { deg, mode = true } = | ||
typeof parsed === "number" ? { deg: parsed } : parsed; | ||
// No need to do extra rotation | ||
deg %= 360; | ||
// no rotation for 0, 360, -360, 720, -720, ... | ||
if (deg % 360 === 0) { | ||
return image; | ||
} | ||
// use matrixRotate if the angle is a multiple of 90 degrees (eg: 180 or -90) and resize is allowed or not needed. | ||
@@ -245,0 +247,0 @@ const matrixRotateAllowed = |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
113372
26
+ Added@jimp/core@1.1.2(transitive)
+ Added@jimp/file-ops@1.1.2(transitive)
+ Added@jimp/plugin-crop@1.1.2(transitive)
+ Added@jimp/plugin-resize@1.1.2(transitive)
+ Added@jimp/types@1.1.2(transitive)
+ Added@jimp/utils@1.1.2(transitive)
- Removed@jimp/core@1.1.1(transitive)
- Removed@jimp/file-ops@1.1.1(transitive)
- Removed@jimp/plugin-crop@1.1.1(transitive)
- Removed@jimp/plugin-resize@1.1.1(transitive)
- Removed@jimp/types@1.1.1(transitive)
- Removed@jimp/utils@1.1.1(transitive)
Updated@jimp/core@1.1.2
Updated@jimp/plugin-crop@1.1.2
Updated@jimp/plugin-resize@1.1.2
Updated@jimp/types@1.1.2
Updated@jimp/utils@1.1.2