add readme and license

This commit is contained in:
tchivert committed 2023-06-30 15:24:16 +02:00
1 parent b57c1f5026
commit c0a7806a4a
2 files changed
+103

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023, tchivert
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+82
View File
@@ -0,0 +1,82 @@
# Image CDN
Image CDN is a lightweight image caching and resizing server written in Go. It provides a simple HTTP interface for fetching and resizing images on the fly.
## Features
- Caches images in Redis for improved performance
- Supports resizing images based on width, height, and percentage
- Handles multiple authorized hosts
- Supports PNG, JPEG, and WebP image formats
## Getting Started
To get started with Image CDN, follow these steps:
1. Clone the repository:
```shell
git clone https://git.rznet.fr/razian/imgcdn
cd imgcdn
```
2. Build the container:
```shell
docker build -t imgcdn .
```
3. Start the container:
```shell
docker run -d -p 8080:8080 --name imgcdn imgcdn
```
Now, the Image CDN server is up and running on port 8080.
## Configuration
The Image CDN server can be configured using command-line arguments. Here are the available configuration options:
- `--config` (optional): Path to a file containing a list of authorized hosts (one host per line)
- `--redis` (optional): Enable or disable Redis caching (true or false; default: true)
- `--redishost` (optional): Hostname of the Redis server (default: localhost)
- `--redisport` (optional): Port of the Redis server (default: 6379)
You can pass these arguments while starting the container:
```shell
docker run -d -p 8080:8080 --name imgcdn imgcdn --config=hosts.cfg --redis=true --redishost=redis
```
## Usage
Once the Image CDN server is running, you can access the images using the following URL pattern:
```
http://<server>:8080/<path-to-image>?w=<width>&h=<height>&p=<percentage>
```
- `<server>`: The hostname or IP address of the server where the Image CDN is running
- `<path-to-image>`: The path to the image on the server
- `<width>` (optional): The desired width of the resized image
- `<height>` (optional): The desired height of the resized image
- `<percentage>` (optional): The percentage of the original image size for resizing (0-100)
For example, to resize an image to a width of 200 pixels:
```
http://<server>:8080/images/photo.jpg?w=200
```
## Redis Caching
By default, Image CDN uses Redis to cache images for improved performance. If Redis caching is enabled (--redis=true), the server will store resized images in Redis for subsequent requests. If Redis caching is disabled (--redis=false), the server will fetch the original image from the URL for each request.
## Authorized Hosts
Image CDN supports restricting requests to specific authorized hosts. You can provide a file containing a list of authorized hosts using the `--config` command-line argument. Each host should be listed on a separate line in the file.
## License
This project is licensed under the MIT License. See the [LICENSE](https://git.rznet.fr/razian/imgcdn/src/branch/main/LICENSE) file for more information.