A simple web tool for quickly cropping and exporting multiple assets from a single image sheet. Upload an image, define your crop areas, and export them as a zip file.
- Interactive Cropping: Use your mouse to draw and resize crop areas directly on the uploaded image.
- Multiple Layers: Create as many crop areas (layers) as you need.
- Customizable Exports: For each layer, you can customize:
- Output dimensions (width, height)
- Fit mode (
containorcover) - Background color
- Output format (
png,jpeg,webp) - Filename
- Presets: Quickly apply predefined dimensions for common use cases (e.g., icons, banners).
- Live Previews: See a live preview of the selected crop's output.
- Bulk Export: Export all your defined crops at once into a single
.zipfile. - Session History: Access previously uploaded images and exported zip files from your current session.
- Frontend:
- React
- TypeScript
- Vite
- Konva.js for the cropping canvas
- Tailwind CSS for styling
- Backend:
-
Clone the repository:
git clone <repository-url> cd asset-clip
-
Install dependencies:
npm install
-
Run the development server: This command starts both the backend server and the Vite development server with Hot Module Replacement (HMR).
npm run dev
-
Open the app: Navigate to
http://localhost:3000in your web browser.
npm run dev: Starts the development server.npm run start: Starts the production server (requires runningnpm run buildfirst).npm run build: Builds the React frontend for production into thedistdirectory.npm run preview: Serves the production build locally for previewing.npm run lint: Runs the TypeScript compiler to check for type errors.npm run clean: Removes thedistdirectory.
The Express backend provides the following API endpoints under the /api prefix:
POST /api/upload: Upload a single image.GET /api/uploads: Get a list of uploaded files for the current session.DELETE /api/uploads: Clear all uploaded files for the session.DELETE /api/uploads/:id: Delete a specific uploaded file.GET /api/image/:id: Serve a specific uploaded image file.POST /api/preview-crop: Generate a temporary preview for a single crop definition.POST /api/export: Export a batch of defined crops as a zip archive.