
Company News
/Security News
Socket Selected for OpenAI's Cybersecurity Grant Program
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.
frontend-image-compress
Advanced tools
A simple function using canvas to compress image file.
<input type='file' id='test'/>
<script src="https://unpkg.com/frontend-image-compress@latest/dist/index.min.js"></script>
<script>
const $file = document.querySelector('#test');
$file.onchange = async function(e) {
const file = e.target.files[0];
window.Compress.compressImageFile(file).then(compressedFile=>{}).catch(err=>{
alert(err.toString())
})
}
</script>
yarn add frontend-image-compressnpm i frontend-image-compressimport { compressImageFile } from 'frontend-image-compress'
const $file = document.querySelector('#test');
$file.onchange = async function(e) {
const file = e.target.files[0];
const compressedFile = await compressImageFile(file)
}
when using script tag, you need to use window.Compress.xx, Compress is just a namespace
| name | type | description |
|---|---|---|
| file | File | from input[type="file"] |
| quality | number | range: 0~1, default is 0.7(decrease this value if you got console warning) |
| return | Promise<File> | compressed file |
3.0.1:
frontend-image-compress.min.js to index.min.js)3.0.0:commonjsFAQs
compress image-type file in frontend using canvas
The npm package frontend-image-compress receives a total of 28 weekly downloads. As such, frontend-image-compress popularity was classified as not popular.
We found that frontend-image-compress 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.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.