A powerful web application that allows you to download, process, and standardize images from various sources. This tool helps you create consistent 1500x1500px images with proper positioning based on the image content.
- Multiple Image Sources: Upload local files or scrape images from webpages
- Intelligent Processing: Automatically resize and position images to 1500x1500px based on content
- Batch Processing: Process multiple images at once with filtering by size
- Download Options: Download individual images or as a ZIP archive
- CORS Handling: Creates placeholders for images that can't be loaded due to CORS restrictions
- Automatic Cleanup: Uploaded files are automatically deleted after 1 hour
- Rate Limiting: All API endpoints are protected with rate limiting to prevent abuse
# Clone the repository
git clone https://github.com/yourusername/nextjs-image-processor.git
cd nextjs-image-processor
# Create a .env file from the example
cp .env.example .env
# Start the application with Docker Compose
docker compose up -dThe application will be available at http://localhost:6060
# Clone the repository
git clone https://github.com/yourusername/nextjs-image-processor.git
cd nextjs-image-processor
# Install dependencies
pnpm install
# Start the development server
pnpm devThe application will be available at http://localhost:3000
Customize the application by setting these environment variables in your .env file:
| Variable | Description | Default |
|---|---|---|
VERSION |
Docker image version to use | latest |
NEXT_PUBLIC_SITE_NAME |
The name of your site | NextJS Image Processor |
NEXT_PUBLIC_SITE_DESCRIPTION |
Site description | A powerful web application... |
NEXT_PUBLIC_SITE_URL |
Your site's URL | https://yourdomain.com |
NEXT_PUBLIC_SITE_THEME_COLOR |
Theme color (hex) | #000000 |
NEXT_PUBLIC_SITE_BACKGROUND_COLOR |
Background color (hex) | #ffffff |
CLEANUP_API_KEY |
API key for the cleanup endpoint | change-this-to-a-secure-key |
NEXT_PUBLIC_DEBUG |
Enable debug logging | false |
The application consists of two main components:
- Main Application: A Next.js application that handles image processing
- Cleanup Service: A service that runs every minute to delete uploaded files older than 1 hour
| Endpoint | Method | Description | Rate Limit |
|---|---|---|---|
/api/images |
POST | Upload and process images | 300 req/min |
/api/proxy |
GET | Proxy for fetching images to avoid CORS issues | 500 req/min |
/api/serve-image |
GET | Serve processed images from the server | 120 req/min |
/api/cleanup |
GET | Trigger cleanup of old uploads (requires API key) | 5 req/min |
/api/healthcheck |
GET | Check if the application is running | 30 req/min |
This project includes comprehensive test coverage with Jest for unit/integration tests and Playwright for end-to-end tests.
# Run all Jest tests
pnpm test
# Run tests in watch mode
pnpm test:watch
# Generate test coverage report
pnpm test:coverage
# Run end-to-end tests
pnpm test:e2eFor running tests in the Docker environment, use the provided script:
# Run all API tests
./docker-test.sh
# Run specific test file
./docker-test.sh __tests__/api/images.test.js
# Run tests for a specific directory
./docker-test.sh __tests__/api/The script handles:
- Setting up the proper test environment
- Configuring mocks for dependencies
- Copying test files to the container
- Running tests with the correct parameters
- Cleaning up temporary files
This project uses pnpm for dependency management. To update dependencies:
# Update dependencies and regenerate lockfile
pnpm update-lockfileFor development with Docker:
# Start the development environment
cd docker && docker-compose -f docker-compose-dev.yml up -d
# Stop the development environment
cd docker && docker-compose -f docker-compose-dev.yml downIf you encounter permission errors when uploading images, ensure the public/uploads directory has proper permissions:
mkdir -p public/uploads
chmod -R 777 public/uploadsIf you encounter HTTP 429 errors, you've exceeded the rate limit for an API endpoint. Wait a minute before trying again.
If Docker healthchecks fail:
- Check container logs:
docker logs nextjs-image-processor - Verify the application is running:
curl http://localhost:6060/api/healthcheck - Restart the container:
docker compose restart app
This project is licensed under the MIT License - see the LICENSE file for details.