• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

fileutils/H16-Nov-2021-202143

routing/H16-Nov-2021-1,4121,138

storage/H16-Nov-2021-1,145788

thumbnailer/H16-Nov-2021-777561

types/H16-Nov-2021-11149

README.mdH A D16-Nov-20211.6 KiB2814

mediaapi.goH A D16-Nov-20211.3 KiB4223

README.md

1# Media API
2
3This server is responsible for serving `/media` requests as per:
4
5http://matrix.org/docs/spec/client_server/r0.2.0.html#id43
6
7## Scaling libraries
8
9### nfnt/resize (default)
10
11Thumbnailing uses https://github.com/nfnt/resize by default which is a pure golang image scaling library relying on image codecs from the standard library. It is ISC-licensed.
12
13It is multi-threaded and uses Lanczos3 so produces sharp images. Using Lanczos3 all the way makes it slower than some other approaches like bimg. (~845ms in total for pre-generating 32x32-crop, 96x96-crop, 320x240-scale, 640x480-scale and 800x600-scale from a given JPEG image on a given machine.)
14
15See the sample below for image quality with nfnt/resize:
16
17![](nfnt-96x96-crop.jpg)
18
19### bimg (uses libvips C library)
20
21Alternatively one can use `go build -tags bimg` to use bimg from https://github.com/h2non/bimg (MIT-licensed) which uses libvips from https://github.com/jcupitt/libvips (LGPL v2.1+ -licensed). libvips is a C library and must be installed/built separately. See the github page for details. Also note that libvips in turn has dependencies with a selection of FOSS licenses.
22
23bimg and libvips have significantly better performance than nfnt/resize but produce slightly less-sharp images. bimg uses a box filter for downscaling to within about 200% of the target scale and then uses Lanczos3 for the last bit. This is a much faster approach but comes at the expense of sharpness. (~295ms in total for pre-generating 32x32-crop, 96x96-crop, 320x240-scale, 640x480-scale and 800x600-scale from a given JPEG image on a given machine.)
24
25See the sample below for image quality with bimg:
26
27![](bimg-96x96-crop.jpg)
28