Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
get-image-orientation
Advanced tools
Utility for determining image orientation and aspect ratio.
Run npm install get-image-orientation --save
import getImageOrientation from 'get-image-orientation';
const image = {
width: 320,
height: 240
};
const {
aspect, // number/int/float
isPortrait, // boolean
isLandscape, // boolean
isSquare, // boolean
widthIncrease, // number/int
heightIncrease, // number/int
isSquareLikePortrait, // boolean
isSquareLikeLandscape // boolean
ratio // string
} = getImageOrientation(image.width, image.height, 10);
getImageOrientation(320, 240, 10);
width - image width, REQUIRED
height - image height, REQUIRED
maxIncrease - max width/height increase in percentage, default = 15. maxIncrease
is used for determining isSquareLikePortrait
and isSquareLikeLandscape
flags.
getImageOrientation
returns the following fields:
Number (int/float)
. This value represents the aspect of the image. It refers to the image height, when that image has a landscape orientation. When the image has a portrait orientation, it refers to its width. Aspect is calculated by the formula image.width / image.height
.
Boolean
. Determines if the image has a portrait orientation. An image has a portrait orientation, when image.width
> image.height
.
Boolean
. Determines if the image has a landscape orientation. An image has a landscape orientation, when image.width
< image.height
.
Boolean
. Determines if the image has a square orientation. An image has a square orientation, when image.width
=== image.height
.
Number (int)
. This value represents the width increase, compared to image.height
in percentage, eg ((width - height) * 100) / width
. Width increase is calculated when isLandscape
is true
. Otherwise, it returns 0
.
Number (int)
. This value represents the height increase, compared to image.width
in percentage, eg ((height - width) * 100) / height
. Height increase is calculated when isPortrait
is true
. Otherwise, it returns 0
.
Boolean
. Determines if the image has a square-like portrait orientation. An image has a square-like portrait orientation, when that image isPortrait
and its heightIncrease
is less than or equal to maxIncrease
. In other words, this check returns true for near-square portrait images, with height just a bit bigger than their width. This check is useful for differentiating standard portrait images from square-like images.
Boolean
. Determines if the image has a square-like landscape orientation. An image has a square-like landscape orientation, when that image isLandscape
and its widthIncrease
is less than or equal to maxIncrease
. This check returns true for near-square landscape images, with width just a bit bigger than their height. This check is useful for differentiating standard landscape images from square-like images.
String
. Represents the closest matching aspect ratio for the image. Available ratios are:
2/3
1/1
4/3
16/10
5/3
16/9
21/9
const orientation = getImageOrientation(1600, 900);
// orientation contains:
{
aspect: 1.78,
isPortrait: false,
isLandscape: true,
isSquare: false,
isSquareLikePortrait: false,
isSquareLikeLandscape: false,
widthIncrease: 43,
heightIncrease: 0,
ratio: '16/9'
}
const orientation = getImageOrientation(322, 480);
// orientation contains:
{
aspect: 0.67,
isPortrait: true,
isLandscape: false,
isSquare: false,
isSquareLikePortrait: false,
isSquareLikeLandscape: false,
widthIncrease: 0,
heightIncrease: 32,
ratio: '2/3'
}
const orientation = getImageOrientation(555, 480);
// orientation contains:
{
aspect: 1.16,
isPortrait: false,
isLandscape: true,
isSquare: false,
isSquareLikePortrait: false,
isSquareLikeLandscape: true,
widthIncrease: 13,
heightIncrease: 0,
ratio: '1/1'
}
const orientation = getImageOrientation(413, 480);
// orientation contains:
{
aspect: 0.86,
isPortrait: true,
isLandscape: false,
isSquare: false,
isSquareLikePortrait: true,
isSquareLikeLandscape: false,
widthIncrease: 0,
heightIncrease: 13,
ratio: '1/1'
}
const orientation = getImageOrientation(480, 480);
// orientation contains:
{
aspect: 1,
isPortrait: false,
isLandscape: false,
isSquare: true,
isSquareLikePortrait: false,
isSquareLikeLandscape: false,
widthIncrease: 0
heightIncrease: 0,
ratio: '1/1'
}
FAQs
Utility for determining image orientation and aspect ratio
The npm package get-image-orientation receives a total of 12 weekly downloads. As such, get-image-orientation popularity was classified as not popular.
We found that get-image-orientation demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.