ImageFlow is an efficient image service system designed for modern websites and applications. It automatically provides the most suitable images based on device type and supports modern image formats like WebP and AVIF, significantly improving website performance and user experience.
libwebp-tools)libavif-apps)git clone https://github.com/Yuri-NagaSaki/ImageFlow.git
cd ImageFlow
cd frontend
bash build.sh
go mod tidy go build -o imageflow
cp .env.example .env
# Edit the .env file with your configuration
[Unit]
Description=ImageFlow Service
After=network.target
[Service]
ExecStart=/path/to/imageflow
WorkingDirectory=/path/to/imageflow/directory
Restart=always
User=youruser
EnvironmentFile=/path/to/imageflow/.env
[Install]
WantedBy=multi-user.target
sudo systemctl enable imageflow
sudo systemctl start imageflow
# 1. Clone the repository
git clone https://github.com/Yuri-NagaSaki/ImageFlow.git
cd ImageFlow
# 2. Configure environment
cp .env.example .env
# Edit the .env file
# 3. Start service
docker compose up -d
# 1. Clone the repository
git clone https://github.com/Yuri-NagaSaki/ImageFlow.git
cd ImageFlow
# 2. Configure environment
cp .env.example .env
# Edit the .env file
# 3. Build and start
docker compose -f docker-compose-build.yml up --build -d
Configure the system by creating and editing the .env file. Here are the main configuration options:
# API Key Configuration
API_KEY=your_api_key_here # Set your API key
# Storage Configuration
STORAGE_TYPE=local # Storage type: local or s3 (S3-compatible storage)
LOCAL_STORAGE_PATH=static/images # Local storage path
# S3 Storage Configuration (required when STORAGE_TYPE=s3)
S3_ENDPOINT= # S3 endpoint address
S3_REGION= # S3 region
S3_ACCESS_KEY= # Access key
S3_SECRET_KEY= # Secret key
S3_BUCKET= # Bucket name
CUSTOM_DOMAIN= # Custom domain
# Image Processing Configuration
MAX_UPLOAD_COUNT=20 # Maximum upload count per request
IMAGE_QUALITY=80 # Image quality (1-100)
WORKER_THREADS=4 # Number of parallel processing threads
COMPRESSION_EFFORT=6 # Compression level (1-10)
FORCE_LOSSLESS=false # Force lossless compression
Image upload functionality requires API key authentication. You can:
.env fileAccess the upload interface at http://localhost:8686/. You can:
Access the management interface at http://localhost:8686/manage.html. You can:
Get random images through the API (no API key required):
GET http://localhost:8686/api/random GET http://localhost:8686/api/random?tag=nature
The system returns the most suitable image based on the device type and browser support in request headers. You can also filter random images by tags.
| Endpoint | Method | Description | Parameters | Authentication |
|---|---|---|---|---|
/api/random | GET | Get a random image | tag: Optional, filter by tag | Not required |
/api/upload | POST | Upload new images | Form data, field name "images[]" Optional: expiryMinutes (expiration time in minutes)Optional: tags (array of tags) | API key required |
/api/delete-image | POST | Delete an image and all its formats | JSON with id and storageType | API key required |
/api/validate-api-key | POST | Validate API key | API key in request header | Not required |
/api/images | GET | List all uploaded images | Optional: tag (filter by tag) | API key required |
/api/config | GET | Get system configuration | None | API key required |
/api/trigger-cleanup | POST | Manually trigger cleanup of expired images | None | API key required |
/api/tags | GET | Get all available tags | None | API key required |
ImageFlow/ ├── .github/ # GitHub related configurations ├── config/ # Configuration related code ├── docs/ # Documentation and images ├── favicon/ # Favicon assets ├── frontend/ # Next.js frontend application │ ├── app/ # Next.js app directory │ ├── public/ # Public assets │ ├── .next/ # Next.js build output │ ├── out/ # Static export output │ ├── build.sh # Build script for Unix │ └── build.bat # Build script for Windows ├── handlers/ # HTTP request handlers ├── scripts/ # Utility scripts ├── static/ # Static files and image storage │ └── images/ # Image storage directory │ ├── landscape/ # Landscape images │ │ ├── avif/ # AVIF format │ │ └── webp/ # WebP format │ ├── portrait/ # Portrait images │ │ ├── avif/ # AVIF format │ │ └── webp/ # WebP format │ ├── original/ # Original images │ │ ├── landscape/ # Original landscape │ │ └── portrait/ # Original portrait │ ├── gif/ # GIF format images │ └── metadata/ # Image metadata (including expiration information) ├── utils/ # Utility functions ├── .env # Environment variables ├── .env.example # Example environment configuration ├── Dockerfile # Docker configuration ├── docker-compose.yaml # Docker Compose configuration ├── docker-compose-build.yml # Docker Compose build configuration ├── go.mod # Go module file ├── go.sum # Go module checksum ├── main.go # Main application entry └── README.md # Project documentation
Contributions are welcome! Feel free to submit code, report issues, or suggest improvements!
This project is licensed under the MIT License - see the LICENSE file for details.
Blog - 猫猫博客
Project Link: https://github.com/Yuri-NagaSaki/ImageFlow
YXVM赞助了本项目
NodeSupport赞助了本项目
⭐ If you like this project, please give it a star! ⭐
Made with ❤️ by Yuri NagaSaki