Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
intrinsic-scale
Advanced tools
Replicate background-size: cover/contain (scale+crop) for canvas/CSS/Node/… on any type of media.
Replicate
background-size: cover/contain
for canvas/CSS/Node/… on any type of media.
Many libraries that take care of replicating background-size
/object-fit
’s cover
/contain
have this functionality embedded. You can use this function anywhere, from the browser to calculate sizing on a canvas, to node when doing some image file resizing.
This module doesn't concern itself with getting the sizes or applying the values. You provide numbers, you get numbers.
npm install intrinsic-scale
import resizeToFit from 'intrinsic-scale';
/*
Given an 50px 50px element in a 100px 200px parent
To be contained by its parent it must be of size 100px 100px
and be positioned at 0px 50px to be centered.
*/
const source = {width: 50, y: 50};
const target = {width: 100, height: 200};
const { width, height, x, y } = resizeToFit('contain', source, target);
console.log(width, height, x, y);
//100 100 0 50
/*
Given an 50px 50px element in a 100px 200px parent
To be covered in its parent it must be of size 200px 200px
and be positioned at -50px 0px to be centered.
*/
const source = {width: 50, y: 50};
const target = {width: 100, height: 200};
const { width, height, x, y } = resizeToFit('cover', source, target);
console.log(width, height, x, y);
//200 200 -50 0
No dependencies. It works in the browser and in node.
FAQs
Replicate background-size: cover/contain (scale+crop) for canvas/CSS/Node/… on any type of media.
We found that intrinsic-scale demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.