A modern image resizing service built with Astro and Sharp, providing an API to resize images from URLs.
- 🚀 Built with Astro for optimal performance
- 🖼️ Resize images with customizable dimensions
- 📐 Maintain aspect ratio when only width or height is specified
- 🔄 Support for multiple formats (JPEG, PNG, WebP)
- 🎨 Modern, responsive UI
- ☁️ Ready for deployment on Vercel
GET /api/resize
| Parameter | Type | Default | Description |
|---|---|---|---|
url |
string | https://picsum.photos/800/600 |
The image URL to resize |
width |
number | 800 |
Target width (optional) |
height |
number | 600 |
Target height (optional) |
format |
string | jpeg |
Output format (jpeg, png, webp) |
# Resize to specific dimensions
curl "http://localhost:4321/api/resize?url=https://picsum.photos/800/600&width=400&height=300"
# Resize width only (maintain aspect ratio)
curl "http://localhost:4321/api/resize?url=https://picsum.photos/800/600&width=400"
# Resize height only (maintain aspect ratio)
curl "http://localhost:4321/api/resize?url=https://picsum.photos/800/600&height=300"
# Convert to PNG
curl "http://localhost:4321/api/resize?url=https://picsum.photos/800/600&width=400&format=png"
# Redirect to original image (no dimensions specified)
curl "http://localhost:4321/api/resize?url=https://picsum.photos/800/600"- Node.js 18+
- npm or yarn
npm installnpm run devThe application will be available at http://localhost:4321
npm run buildnpm run previewThis project is configured for deployment on Vercel with the @astrojs/vercel adapter.
- Push your code to GitHub
- Connect your repository to Vercel
- Deploy automatically
The API routes will be available as serverless functions on Vercel.
src/
├── pages/
│ ├── index.astro # Main documentation page
│ ├── take.astro # Redirect page for backward compatibility
│ └── api/
│ └── resize.ts # Image resizing API endpoint
├── config/
│ └── screenshot.ts # Configuration parameters
├── components/ # Astro components (if any)
└── layouts/ # Layout components (if any)
- Astro - Web framework
- @astrojs/vercel - Vercel adapter
- Sharp - High-performance image processing
ISC