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.
compress.js
Advanced tools
A JavaScript client side image compression. This library uses the Canvas API to compress the image, and thus will not work on the node.js server-side.
Maintaining open source is not easy. Would be great if you could show some support!
There are several limitations for this library:
image/gif
, the compressed image will no longer animate.image/png
with transparent background, the compressed image will lose transparency and result in black background.NPM Package here.
npm install compress.js --save
const Compress = require('compress.js')
You can also include the build/compress.min.js
in your project directory, and then importing it using type module
in the script tag.
<!-- index.html -->
<script type="module" src="index.js"></script>
// index.js
import Compress from "./compress.min.js";
// ...
Try out our demo here.
import Compress from "./compress.min.js";
const compressor = new Compress();
// Listen to file upload events.
upload.addEventListener(
"change",
async function (evt) {
const file = evt.target.files[0];
const newFile = await compressor.compress(file, {
quality: 0.95,
crop: true, // If true, will crop a square image from the center.
maxWidth: 320, // Image width will not exceed 320px.
maxHeight: 320, // Image height will not exceed 320px.
});
// Display the image on the img element.
img.src = URL.createObjectURL(newFile);
},
FAQs
A client side JavaScript image compression library
We found that compress.js demonstrated a healthy version release cadence and project activity because the last version was released less than 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
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.