1
0
mirror of https://github.com/matrix-org/dendrite.git synced 2024-06-20 07:47:07 +00:00
matrix-org.dendrite/mediaapi
Abhinav Krishna C K ec38783192
maintenance: Fix matrix-org#896 use %w format verb to wrap errors (#916)
* maintenance: Fix matrix-org#896 use %w format verb to wrap errors

* In Go version 1.13 a new formatting verb introduced for fmt.Errorf
  %w https://blog.golang.org/go1.13-errors

* update %s to %w to wrap errors.

* Update all instances of error type to use %w

Signed-off-by: Abhinav Krishna C K <me@abhy.me>

Co-authored-by: Kegsay <kegan@matrix.org>
2020-03-18 12:48:51 +00:00
..
fileutils maintenance: Fix matrix-org#896 use %w format verb to wrap errors (#916) 2020-03-18 12:48:51 +00:00
routing Support sqlite in addition to postgres (#869) 2020-02-13 17:27:33 +00:00
storage Log errors from rows.Close (#920) 2020-03-18 10:17:18 +00:00
thumbnailer Implement storage interfaces (#841) 2020-01-03 14:07:05 +00:00
types use go module for dependencies (#594) 2019-05-21 21:56:55 +01:00
bimg-96x96-crop.jpg use go module for dependencies (#594) 2019-05-21 21:56:55 +01:00
mediaapi.go Support sqlite in addition to postgres (#869) 2020-02-13 17:27:33 +00:00
nfnt-96x96-crop.jpg use go module for dependencies (#594) 2019-05-21 21:56:55 +01:00
README.md Update Docker files and remove references to gb (#703) 2019-05-22 10:44:25 +01:00

Media API

This server is responsible for serving /media requests as per:

http://matrix.org/docs/spec/client_server/r0.2.0.html#id43

Scaling libraries

nfnt/resize (default)

Thumbnailing 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.

It 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.)

See the sample below for image quality with nfnt/resize:

bimg (uses libvips C library)

Alternatively 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.

bimg 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.)

See the sample below for image quality with bimg: