百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
P

pepic

> 开发工具
开源

我的个人项目的图像和视频代理

99 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

我的个人项目的图像和视频代理

Pepic is a small self-hosted media proxy that helps me to upload, store, serve and convert pictures and videos on my own servers.

Currently, I use it as a main storage for media files in my pet-projects and on my blog.

Pepic can upload and optimize media files in-flight to save you money and bandwidth. It's highly recommended to set ip up in combination with Cloudflare CDN for better caching.

Internally it uses ffmpeg for videos and vips for images, which makes it quite fast and supports many media file formats.

Images: JPG, PNG, GIF, WEBP, SVG, HEIF, TIFF, AVIF, etc

Video: basically everything ffmpeg supports

Pepic is open source, however it's not meant to be used by anyone. Only if you're brave (like me). Scroll down this README for better alternatives.

Features

  • Local file storage: Upload files as multipart/form-data or as a simple byte stream and store them to a local directory.
  • Automatic GIF to video conversion: Because GIFs suck, they slow down web pages and don't support hardware acceleration.
  • Image and video transcoding and quality optimization: Transcode and optimize media files on upload or on-the-fly. If you are doing a public storage, you can pre-set your own quality settings to save disk space and bandwidth.
  • Dynamic resizing: Easily resize images just by modifying original URL. You can automatically generate image/video previews on demand without uploading multiple versions of the file.
  • High performance: Pepic uses native libraries like ffmpeg and vips for video and image processing to ensure high performance and fast processing times.
  • Local and containerized environments: Designed to run smoothly in both local environments and within Docker containers, making it versatile for development and deployment.
  • Custom configuration: Flexible configuration options through config.yml, allowing adjustments to image size, quality, automatic conversion, templates, etc.

How to Run

  1. Install vips and ffmpeg first, as they are two main external dependencies
bash
brew install vips ffmpeg
  1. Clone this repo
bash
git clone [email protected]:vas3k/pepic.git
cd pepic
  1. Run the following command to build and start the app
bash
go run main.go serve --config ./etc/pepic/config.yml

⚠️ If you're getting invalid flag in pkg-config error, run brew install pkg-config and export CGO_CFLAGS_ALLOW="-Xpreprocessor". Then try go run again.

  1. Go to localhost:8118 and enjoy!

Using Docker Compose

You can find docker-compose.example.yml in this repo and adapt it to your own needs.

  1. Get Docker and Docker Compose

  2. Download the Docker Compose example file and save it as docker-compose.yml on your local machine

bash
curl https://raw.githubusercontent.com/vas3k/pepic/master/docker-compose.example.yml -o docker-compose.yml
  1. Now run it
bash
docker-compose up
  1. Go to http://localhost:8118 and try uploading something. You should see uploaded images or videos in the local directory (./uploads) after that.

Usage

Configuration options

…

Resizing images on demand

If your image URL looks like this: https://imgs.com/file.jpg

Add /500/ to its URL to get 500px (on the long side) version: https://imgs.com/500/file.jpg

Works only if live_resize option is set to true. If live_resize=false — it returns the original version. Same for video transcoding (where it's off by default).

⚠️ Note: Each resized version is saved as a separate file (with the same hash). When the same version of the file is requested again, Pepic just read it from disk and does not waste CPU time resizing it again. However, if you have many resized versions stored, this can eat quite a bit of disk space. Be careful.

Converting file formats on demand

// Not implemented yet, sorry... PRs are welcome

GIF to video conversion

Because GIFs are terrible, Pepic automatically converts them to mp4 videos by default. You can change it to any other format you like using gif_convert setting in config.yml.

You can disable this behavior only if you set the store_originals=true flag, then GIF files will be saved "as is".

Production Deployment

⚠️ If you plan to host anything bigger than a blog, always put Pepic behind a CDN. CloudFlare offers a free one if you don't hate big corporations :D

Let's say, you want to host it on https://media.mydomain.org

  1. Modify etc/pepic/config.yml to your taste
yaml
global:
  host: 0.0.0.0 
  port: 8118  # internal host and port, leave it as it is
  base_url: "https://media.mydomain.org"
  secret_code: "secretpass"
  max_upload_size: "500M"
  1. Build and run production version of the Docker container

Don't forget to mount upload volume to store files on host (or you can lose those files when the container is killed).

bash
docker run -p 8118:8118 -v /host/dir/uploads:/app/uploads --restart=unless-stopped $(docker build -q .)

If you prefer docker-compose, you can use it too. Check out the included docker-compose.example.yml. You can easily transform it into your favourite k8s config or whatever is fashionable this summer.

Don't forget to periodically backup the /host/dir/uploads directory just in case :)

  1. Use nginx, traefik, k8s or your other favourite proxy

Just proxy all calls from the domain (media.mydomain.org) to Pepic backend (0.0.0.0:8118). Don't forget to set max file size and proxy timeot directives to avoid gateway errors on big files (especially videos).

Here's an example for nginx:

…

Contributions

Contributions are welcome.

Open an Issue if you want to report a bug or propose an idea.

✅ TODO

  • Tests :D
  • Upload by URL
  • Crop, rotate and other useful transformations (face blur? pre-loader generator?)
  • Live conversion by changing file's extension
  • Set format and media quality during the upload (using GET/POST params?)

Alternatives

After reading all this, you probably realized how bad it is and looking for other alternatives. Here's my recommendations:

  • imgproxy
  • imaginary
  • flyimg

‍ License

It's MIT.

Contact me if you have any questions — [email protected].

❤️

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Gogolangimage-processingimage-storagemedia-proxy

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类开发工具
定价开源

> 相关工具

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具