编程开源技术交流,分享技术与知识

网站首页 > 开源技术 正文

Go实战项目:打造一个七牛云图片处理服务

wxchong 2024-07-19 06:06:18 开源技术 18 ℃ 0 评论

项目地址:https://github.com/pierrre/imageserver

简介

An image server toolkit in Go (Golang)【Go中的图像服务器工具包】

几年前的项目了,今天偶然又看到了,仍然还是1.9K的人气,作者已经断更~

开源的项目嘛,能用就可以了~,上手玩玩,文章主要采用了github里的示例。

但有一个大点【HTTP server】,也就是项目是可以最终作为api扩展给业务使用,喜欢的朋友可以深入试玩。

功能模块

  • HTTP server
  • Resize (GIFT, nfnt resize, Graphicsmagick)
  • Rotate
  • Crop
  • Convert (JPEG, GIF (animated), PNG , BMP, TIFF, ...)
  • Cache (groupcache, Redis, Memcache, in memory)
  • Gamma correction
  • Fully modular

示例

  • Simple
  • Advanced
  • Cache
  • Groupcache
  • HTTP Source
  • Mandelbrot (see interactive demo)

以下示例来自项目Advanced包中

调整图片大小

参数

示例

width=200
(preserve aspect ratio)

height=200
(preserve aspect ratio)

width=200&height=200
(change aspect ratio)

width=200&height=200&mode=fit
(fit in 200x200)

width=200&height=200&mode=fill
(fill 200x200 and crop)

旋转

参数

示例

rotation=90
(counterclockwise)

rotation=45&background=ffaa88
(background)

裁剪

Format: min_x,min_y|max_x,max_y

参数

示例

crop=556,111|2156,1711

crop=956,511|1756,1311

crop=1252,799|1460,1022

GIF动画

Original

Resized



重采样

Resampling

Rings

Large

Nearest neighbor

Box

Linear

Cubic

Lanczos

调整图片质量

JPEG quality

Result

5%

10%

50%

GIF转JPEG

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表