Imagor is a like a flash, Docker-ready image processing server written in Poke.
Imagor makes use of concept to be one of many most atmosphere good image processing library
libvips (with govips). It’s miles usually 4-8x sooner than the utilization of the quickest ImageMagick and GraphicsMagick settings.
Featured Content Ads
add advertising hereImagor is a Poke library that is easily extensible, able to be build in and weak in any Unix atmosphere, and able to be containerized the utilization of Docker.
Imagor adopts the Thumbor URL syntax and covers various the web image processing use cases. If these fit your requirements, Imagor would be a gentle-weight, high efficiency fall-in replacement.
Swiftly Originate
docker speed -p 8000: 8000 shumc/imagor -imagor-unsafe
Strive out the following image URLs:
Featured Content Ads
add advertising here# customary images
https://uncooked.githubusercontent.com/golang-samples/gopher-vector/grasp/gopher.png
https://uncooked.githubusercontent.com/golang-samples/gopher-vector/grasp/gopher-front.png
http://localhost: 8000/unsafe/500x500/high/https://uncooked.githubusercontent.com/golang-samples/gopher-vector/grasp/gopher.png
http://localhost: 8000/unsafe/fit-in/500x500/filters:absorb(white):layout(jpeg)/uncooked.githubusercontent.com/golang-samples/gopher-vector/grasp/gopher.png
http://localhost: 8000/unsafe/fit-in/-500x500/10x10/filters:hue(290):saturation(100):absorb(yellow):layout(jpeg):quality(80)/uncooked.githubusercontent.com/golang-samples/gopher-vector/grasp/gopher.png
http://localhost: 8000/unsafe/fit-in/800x800/filters:absorb(white):watermark(uncooked.githubusercontent.com/golang-samples/gopher-vector/grasp/gopher-front.png,repeat,bottom,10):layout(jpeg)/uncooked.githubusercontent.com/golang-samples/gopher-vector/grasp/gopher.png
Docker Develop Instance
Imagor with File Loader and Storage the utilization of mounted quantity:
version: "3" products and services: imagor: image: shumc/imagor:most modern volumes: - ./:/mnt/knowledge atmosphere: PORT: 8000 IMAGOR_UNSAFE: 1 # unsafe URL for attempting out FILE_LOADER_BASE_DIR: /mnt/knowledge # enable file loader by specifying defective dir FILE_STORAGE_BASE_DIR: /mnt/knowledge # enable file storage by specifying defective dir ports: - "8000: 8000"
Imagor with AWS S3 Loader and Storage:
Featured Content Ads
add advertising hereversion: "3" products and services: imagor: image: shumc/imagor:most modern atmosphere: PORT: 8000 IMAGOR_SECRET: mysecret # secret key for URL signature AWS_ACCESS_KEY_ID: ... AWS_SECRET_ACCESS_KEY: ... AWS_REGION: ... S3_LOADER_BUCKET: mybucket # enable S3 loader by specifying loader bucket S3_LOADER_BASE_DIR: images # non-compulsory S3_STORAGE_BUCKET: mybucket # enable S3 storage by specifying storage bucket S3_STORAGE_BASE_DIR: images # non-compulsory ports: - "8000: 8000"
Imagor Endpoint
Imagor endpoint is a chain of URL formulation which defines the image operations, adopted by the image URI:
/HASH|unsafe/clear/AxB:CxD/fit-in/stretch/-Ex-F/GxH/HALIGN/VALIGN/natty/filters:NAME(ARGS):NAME(ARGS):.../IMAGE
HASH
is the URL Signature hash, orunsafe
if unsafe mode is weakclear
eliminates surrounding put aside in images the utilization of high-left pixel colorAxB:CxD
approach manually reduce the image at left-high levelAxB
and perfect-bottom levelCxD
fit-in
approach that the generated image must always gentle now not be auto-cropped and otherwise real fit in an imaginary box specified byExF
stretch
approach resize the image toExF
without keeping its aspect ratios-Ex-F
approach resize the image to beExF
of width per height size. The minus indicators indicate flip horizontally and verticallyGxH
add horizontal paddingG
and vertical paddingH
belowfit-in
HALIGN
is horizontal alignment of reduce. Acceptsleft
,ultimate
orheart
, defaults toheart
VALIGN
is vertical alignment of reduce. Acceptshigh
,bottom
orheart
, defaults toheart
natty
approach the utilization of natty detection of focal aspectsfilters
a pipeline of image filter operations to be applied, watch filters portionIMAGE
is the image URI
Imagor presents utilities for previewing and producing Imagor endpoint URI:
GET /params
Prepending /params
to the present endpoint returns the endpoint attributes in JSON scheme, important for preview:
“hash”: “g5bMqZvxaQK65qFPaP1qlJOTuLM=”,
“fit_in”: true,
“width”: 500,
“height”: 400,
“v_padding”: 20,
“filters”: [
{
“name”: “fill”,
“args”: “white”
}
]
}”>
curl http://localhost: 8000/params/g5bMqZvxaQK65qFPaP1qlJOTuLM=/fit-in/500x400/0x20/filters:absorb(white)/uncooked.githubusercontent.com/golang-samples/gopher-vector/grasp/gopher.png
{
"course": "fit-in/500x400/0x20/filters:absorb(white)/uncooked.githubusercontent.com/golang-samples/gopher-vector/grasp/gopher.png",
"image": "uncooked.githubusercontent.com/golang-samples/gopher-vector/grasp/gopher.png",
"hash": "g5bMqZvxaQK65qFPaP1qlJOTuLM=",
"fit_in": correct,
"width": 500,
"height": 400,
"v_padding": 20,
"filters": [
{
"name": "fill",
"args": "white"
}
]
}
imagorpath
equipment
Imagor Poke library presents a imagorpath
equipment which
permits you to parse and generate Imagor endpoint the utilization of the Params
struct:
FitIn: true,
Width: 500,
Height: 400,
VPadding: 20,
Filters: imagorpath.Filters{
{
Name: “fill”,
Args: “white”,
},
},
}
// generate signed Imagor endpoint from Params struct with secret
path := imagorpath.Generate(params, “mysecret”)
assert.Equal(t, path, “g5bMqZvxaQK65qFPaP1qlJOTuLM=/fit-in/500×400/0x20/filters:fill(white)/raw.githubusercontent.com/golang-samples/gopher-vector/master/gopher.png“)
}
“>
import "github.com/cshum/imagor/imagorpath" ... func Take a look at(t *attempting out.T) { params := imagorpath.Params{ Image: "uncooked.githubusercontent.com/golang-samples/gopher-vector/grasp/gopher.png", FitIn: correct, Width: 500, Top: 400, VPadding: 20, Filters: imagorpath.Filters{ { Name: "absorb", Args: "white", }, }, } // generate signed Imagor endpoint from Params struct with secret course := imagorpath.Generate(params, "mysecret") tell.Equal(t, course, "g5bMqZvxaQK65qFPaP1qlJOTuLM=/fit-in/500x400/0x20/filters:absorb(white)/uncooked.githubusercontent.com/golang-samples/gopher-vector/grasp/gopher.png") }
URL Signature
In production atmosphere, it is vitally instructed turning off IMAGOR_UNSAFE
and setup IMAGOR_SECRET
to lead faraway from DDoS assaults that abuse extra than one image operations.
The hash is in accordance to HMAC digest, created by taking the URL course (excluding /unsafe/) with secret. The hash is then defective64url-encoded.
An instance in Poke:
// RArq3FZw_bqxLcpKo1WI0aX_q7s=/fit-in/500×500/filters:fill(white):format(jpeg)/raw.githubusercontent.com/golang-samples/gopher-vector/master/gopher.png
}”>
func SignPath(course, secret string) string { h := hmac.Contemporary(sha1.Contemporary, []byte(secret)) h.Write([]byte(strings.TrimPrefix(course, "/"))) hash := defective64.URLEncoding.EncodeToString(h.Sum(nil)) return hash + "/" + course } func most important() { fmt.Println(SignPath("500x500/high/uncooked.githubusercontent.com/golang-samples/gopher-vector/grasp/gopher.png", "mysecret")) // RArq3FZw_bqxLcpKo1WI0aX_q7s=/fit-in/500x500/filters:absorb(white):layout(jpeg)/uncooked.githubusercontent.com/golang-samples/gopher-vector/grasp/gopher.png }
Filters
Filters /filters:NAME(ARGS):NAME(ARGS):.../
is a pipeline of image operations that might maybe be sequentially applied to the image. Examples:
/filters:absorb(white):layout(jpeg)/
/filters:hue(290):saturation(100):absorb(yellow):layout(jpeg):quality(80)/
/filters:absorb(white):watermark(uncooked.githubusercontent.com/golang-samples/gopher-vector/grasp/gopher-front.png,repeat,bottom,10):layout(jpeg)/
Imagor supports the following filters:
background_color(color)
sets the background color of a transparent imagecolor
the color title or hexadecimal rgb expression without the “#” personality
blur(sigma)
applies gaussian blur to the imagebrightness(quantity)
increases or decreases the image brightnessquantity
-100 to 100, the quantity in % to expand or lower the image brightness
distinction(quantity)
increases or decreases the image distinctionquantity
-100 to 100, the quantity in % to expand or lower the image distinction
absorb(color)
absorb the missing put aside or transparent image with the desired color:color
– color title or hexadecimal rgb expression without the “#” personality- If color is “blur” – missing formulation are stuffed with blurred customary image.
- If color is “auto” – the tip left image pixel might maybe be chosen because the filling color
layout(layout)
specifies the output layout of the imagelayout
accepts jpeg, png, webp, gif, jp2, tiff
grayscale()
adjustments the image to grayscalehue(angle)
increases or decreases the image hueangle
the angle in level to expand or lower the hue rotation
quality(quantity)
adjustments the total quality of the image, does nothing for pngquantity
0 to 100, the usual level in %
rgb(r,g,b)
quantity of color in every of the rgb channels in %. Can fluctuate from -100 to 100rotate(angle)
rotates the given image per the angle worth handedangle
accepts 0, 90, 180, 270
round_corner(rx [, ry [, color]])
provides rounded corners to the image with the desired color as backgroundrx
,ry
quantity of pixel to utilize as radius. ry = rx if ry is now not providedcolor
the color title or hexadecimal rgb expression without the “#” personality
saturation(quantity)
increases or decreases the image saturationquantity
-100 to 100, the quantity in % to expand or lower the image saturation
sharpen(sigma)
sharpens the imageclear([tolerance [, position]])
practice clear operation as phase of the filter pipelinetolerance
the euclidean distance between the colours to web trimmed internal the tolerance, default 1put aside
default the utilization ofhigh-left
pixel color except specifiedbottom-ultimate
upscale()
upscale the image iffit-in
is weakwatermark(image, x, y, alpha [, w_ratio [, h_ratio]])
provides a watermark to the image. It can in all probability maybe maybe maybe also additionally be positioned internal the image with the alpha channel specified and optionally resized in accordance to the image size by specifying the ratioimage
watermark image URI, the utilization of the same image loader configured for Imagorx
horizontal put aside that the watermark might maybe be in:- Certain numbers indicate put besides the left and detrimental numbers indicate put besides the ultimate.
- Number adopted by a
p
e.g. 20p approach calculating the worth from the image width as percentage left
,ultimate
,heart
positioned left, ultimate or centered respectivelyrepeat
the watermark might maybe be repeated horizontally
y
vertical put aside that the watermark might maybe be in:- Certain numbers indicate put besides the tip and detrimental numbers indicate put besides the bottom.
- Number adopted by a
p
e.g. 20p approach calculating the worth from the image height as percentage high
,bottom
,heart
positioned high, bottom or centered respectivelyrepeat
the watermark might maybe be repeated vertically
alpha
watermark image transparency, a bunch between 0 (fully opaque) and 100 (fully transparent).w_ratio
percentage of the width of the image the watermark must always gentle fit-inh_ratio
percentage of the height of the image the watermark must always gentle fit-in
Configurations
Imagor supports narrate-line arguments, watch available ideas imagor -h
. That you just would be capable to also unbiased test most important.spin for better working out the initialization sequences.
Imagor additionally supports atmosphere variables or .env
file for the arguments similar in capitalized snake case. For cases -imagor-secret
would turn into IMAGOR_SECRET
:
# every are similar
imagor -debug -imagor-secret=1234
DEBUG=1 IMAGOR_SECRET=1234 imagor
Readily available ideas:
Enable CORS
-server-strip-query-string
Enable strip query string redirection
-server-path-prefix string
Server path prefix
-vips-concurrency-level int
VIPS concurrency level. Default to the number of CPU cores.
-vips-disable-blur
VIPS disable blur operations for vips processor
-vips-disable-filters string
VIPS disable filters by csv e.g. blur,watermark,rgb
-vips-max-filter-ops int
VIPS maximum number of filter operations allowed (default 10)
–http-loader-allowed-sources string
HTTP Loader allowed hosts whitelist to load images from if set. Accept csv wth glob pattern e.g. *.google.com,*.github.com.
-http-loader-default-scheme string
HTTP Loader default scheme if not specified by image path. Set “nil” to disable default scheme. (default “https”)
–http-loader-forward-headers string
Forward request header to HTTP Loader request by csv e.g. User-Agent,Accept
–http-loader-forward-all-headers
Forward all request headers to HTTP Loader request
–http-loader-insecure-skip-verify-transport
HTTP Loader to use HTTP transport with InsecureSkipVerify true
–http-loader-max-allowed-size int
HTTP Loader maximum allowed size in bytes for loading images if set
–http-loader-disable
Disable HTTP Loader
-file-loader-base-dir string
Base directory for File Loader. Will activate File Loader only if this value present
-file-loader-path-prefix string
Base path prefix for File Loader
-file-storage-base-dir string
Base directory for File Storage. Will activate File Storage only if this value present
-file-storage-path-prefix string
Base path prefix for File Storage
-file-storage-mkdir-permission string
File Storage mkdir permission (default “0755”)
-file-storage-write-permission string
File Storage write permission (default “0666”)
-aws-access-key-id string
AWS Access Key ID. Required if using S3 Loader or S3 Storage
-aws-region string
AWS Region. Required if using S3 Loader or S3 Storage
-aws-secret-access-key string
AWS Secret Access Key. Required if using S3 Loader or S3 Storage
-s3-loader-base-dir string
Base directory for S3 Loader
-s3-loader-bucket string
S3 Bucket for S3 Loader. Will activate S3 Loader only if this value present
-s3-loader-path-prefix string
Base path prefix for S3 Loader
-s3-storage-base-dir string
Base directory for S3 Storage
-s3-storage-bucket string
S3 Bucket for S3 Storage. Will activate S3 Storage only if this value present
-s3-storage-path-prefix string
Base path prefix for S3 Storage
-s3-storage-acl string
Upload ACL for S3 Storage (default “public-read”)
“>
imagor -h
Utilization of imagor:
-debug
Debug mode
-port int
Slash port (default 8000)
-imagor-secret string
Secret key for signing Imagor URL
-imagor-unsafe
Unsafe Imagor that would not require URL signature. Inclined to URL tampering
-imagor-version
Imagor version
-imagor-cache-header-ttl duration
Imagor HTTP cache header ttl for a hit image response (default 24h0m0s)
-imagor-seek knowledge from-timeout duration
Timeout for performing imagor seek knowledge from (default 30s)
-imagor-load-timeout duration
Timeout for Imagor Loader seek knowledge from, must always be smaller than imagor-seek knowledge from-timeout (default 20s)
-imagor-build-timeout duration
Timeout for saving image for storage (default 1m0s)
-server-contend with string
Server contend with
-server-cors
Allow CORS
-server-strip-request-string
Allow strip request string redirection
-server-course-prefix string
Server course prefix
-vips-concurrency-level int
VIPS concurrency level. Default to the sequence of CPU cores.
-vips-disable-blur
VIPS disable blur operations for vips processor
-vips-disable-filters string
VIPS disable filters by csv e.g. blur,watermark,rgb
-vips-max-filter-ops int
VIPS maximum sequence of filter operations allowed (default 10)
-http-loader-allowed-sources string
HTTP Loader allowed hosts whitelist to load images from if scheme. Accept csv wth glob sample e.g. *.google.com,*.github.com.
-http-loader-default-plan string
HTTP Loader default plan if now not specified by image course. Space "nil" to disable default plan. (default "https")
-http-loader-ahead-headers string
Forward seek knowledge from header to HTTP Loader seek knowledge from by csv e.g. User-Agent,Accept
-http-loader-ahead-all-headers
Forward all seek knowledge from headers to HTTP Loader seek knowledge from
-http-loader-scared-skip-take a look at-transport
HTTP Loader to utilize HTTP transport with InsecureSkipVerify correct
-http-loader-max-allowed-size int
HTTP Loader maximum allowed size in bytes for loading images if scheme
-http-loader-disable
Disable HTTP Loader
-file-loader-defective-dir string
Sinister directory for File Loader. Will activate File Loader most fantastic if this worth display conceal
-file-loader-course-prefix string
Sinister course prefix for File Loader
-file-storage-defective-dir string
Sinister directory for File Storage. Will activate File Storage most fantastic if this worth display conceal
-file-storage-course-prefix string
Sinister course prefix for File Storage
-file-storage-mkdir-permission string
File Storage mkdir permission (default "0755")
-file-storage-write-permission string
File Storage write permission (default "0666")
-aws-web entry to-key-id string
AWS Receive admission to Key ID. Required if the utilization of S3 Loader or S3 Storage
-aws-location string
AWS Blueprint. Required if the utilization of S3 Loader or S3 Storage
-aws-secret-web entry to-key string
AWS Secret Receive admission to Key. Required if the utilization of S3 Loader or S3 Storage
-s3-loader-defective-dir string
Sinister directory for S3 Loader
-s3-loader-bucket string
S3 Bucket for S3 Loader. Will activate S3 Loader most fantastic if this worth display conceal
-s3-loader-course-prefix string
Sinister course prefix for S3 Loader
-s3-storage-defective-dir string
Sinister directory for S3 Storage
-s3-storage-bucket string
S3 Bucket for S3 Storage. Will activate S3 Storage most fantastic if this worth display conceal
-s3-storage-course-prefix string
Sinister course prefix for S3 Storage
-s3-storage-acl string
Upload ACL for S3 Storage (default "public-read")