- Home
- Skills
- Frontend & Web Apps
- Compressly Image Compression
Compressly Image Compression
Compress and resize images in the browser before upload with compressly: target size, WebP/JPEG, EXIF rotation, Web Worker.
Free
Works with the AI Agents you already use
Compressly Image Compression
Example session with this skill installed
Set up a React component that compresses user uploads to under 1MB and converts them to WebP using the compressly hook.
- Read your context and instructions
- Compiled the compressly image compression
I have integrated compressly/react into a new ImageUploader component. This implementation uses the useImageCompressor hook to handle WebP conversion and enforces a 1MB size limit before the upload reaches the server.
React WebP Compressor Component
"use client";
import React from 'react';
import { useImageCompressor } from "compressly/react";
export const ImageUploader = ({ onUploadSuccess }: { onUploadSuccess: (file: File) => void }) => {
const {
compress,
isCompressing,
progress,
phase,
error
} = useImageCompressor({
maxSizeMB: 1,
mimeType: "image/webp",
maxWidth: 1920,
quality: 0.82,
useWorker: true
});
const handleFileChange = async (e: React.ChangeEvent<HTMLInputElement>) => {
const file = e.target.files?.[0];
if (!file) return;
try {
const result = await compress(file);
onUploadSuccess(result.file);
} catch (err) {
console.error("Compression failed:", err);
}
};
return (
<div className="flex flex-col gap-4 p-4 border rounded-lg">
<input
type="file"
accept="image/*"
onChange={handleFileChange}
disabled={isCompressing}
className="block w-full text-sm text-gray-500"
/>
{isCompressing && (
<div className="w-full">
<div className="flex justify-between text-xs mb-1">
<span>{phase}...</span>
<span>{progress}%</span>
</div>
<div className="w-full bg-gray-200 h-2 rounded-full">
<div
className="bg-blue-600 h-2 rounded-full transition-all"
style={{ width: `${progress}%` }}
/>
</div>
</div>
)}
{error && <p className="text-red-500 text-sm">{error.message}</p>}
</div>
);
};
Next steps
- Run
npm install compresslyto add the required dependency. - Pass an upload handler to the component to send the compressed
Fileto your backend API. - Add server-side validation to verify the
Filesize and MIME type for security.
Connects securely to your tools. The creator never sees your data.
About this skill
Large image uploads break server-side constraints and frustrate users on slow mobile networks. This skill implements client-side image optimization to reduce file sizes before they ever leave the user's browser.
What it does
- Pre-upload compression reduces file sizes using the
compresslypackage to save bandwidth and storage costs. - Client-side resizing enforces maximum width and height constraints to keep layouts consistent.
- Format conversion handles transformation between WebP, JPEG, and PNG formats in the browser.
- Batch processing manages multiple file uploads simultaneously with configurable concurrency and progress tracking.
- EXIF handling automatically corrects image orientation and rotation based on camera metadata.
How it works
- Analyze requirements to determine target file sizes, dimensions, and preferred output formats like WebP.
- Install and configure the
compresslydependency and set up theCompressOptionsobject. - Implement processing using
compressImagefor single files orcompressImagesfor batch workflows. - Integrate UI feedback via the
useImageCompressorReact hook to show progress, compression phases, and results.
Frameworks & tools
This tool works with React, Next.js, Vue, Svelte, and vanilla JavaScript. It utilizes browser-native APIs including Canvas and Web Workers via OffscreenCanvas.
Why this beats prompting it yourself
Writing reliable browser-based image processing requires complex Canvas manipulation, Web Worker orchestration, and EXIF metadata parsing. This skill provides a tested, zero-dependency implementation that avoids common UI freezing and memory leaks during large file processing.
Use cases
- Optimizing user avatars or profile photos in React forms.
- Reducing high-resolution listing images for e-commerce marketplaces.
- Handling multi-file photo uploads in messaging or social applications.
- Preventing 'file too large' errors on serverless functions and storage buckets.
Known limitations
Does not support server-side or build-time optimization. Not suitable for lossless archival quality, RAW, or HEIC editing. Requires browser Canvas and File API support.
Source and latest version: https://github.com/Mostafashadow1/agent-skills (MIT licensed, free). npm: https://www.npmjs.com/package/compressly · Docs: https://compress-ly.vercel.app/. Author: Mostafa Shadow.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Frontend & Web Apps.
Requires browser APIs (Canvas, File). Not for Node.js server-side environments. No support for RAW or HEIC editing.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
1 use
Times used to date
Free to use
No account required to browse
Trust & safety
Security scan
Security scan passed 25 days ago
- Free with an Agensi account