mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-28 17:23:09 -06:00
* vendor: Add bimg image processing library bimg is MIT licensed. It depends on the C library libvips which is LGPL v2.1+ licensed. libvips must be installed separately. * mediaapi: Add YAML config file support * mediaapi: Add thumbnail support * mediaapi: Add missing thumbnail files * travis: Add ppa and install libvips-dev * travis: Another ppa and install libvips-dev attempt * travis: Add sudo: required for sudo apt* usage * mediaapi/thumbnailer: Make comparison code more readable * mediaapi: Simplify logging of thumbnail properties * mediaapi/thumbnailer: Rename metrics to fitness Metrics is used in the context of monitoring with Prometheus so renaming to avoid confusion. * mediaapi/thumbnailer: Use math.Inf() for max aspect and size * mediaapi/thumbnailer: Limit number of parallel generators Fall back to selecting from already-/pre-generated thumbnails or serving the original. * mediaapi/thumbnailer: Split bimg code into separate file * vendor: Add github.com/nfnt/resize pure go image scaler * mediaapi/thumbnailer: Add nfnt/resize thumbnailer * travis: Don't install libvips-dev via ppa * mediaapi: Add notes to README about resizers * mediaapi: Elaborate on scaling libs in README
39 lines
604 B
Go
39 lines
604 B
Go
package bimg
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestRead(t *testing.T) {
|
|
buf, err := Read("fixtures/test.jpg")
|
|
|
|
if err != nil {
|
|
t.Errorf("Cannot read the image: %#v", err)
|
|
}
|
|
|
|
if len(buf) == 0 {
|
|
t.Fatal("Empty buffer")
|
|
}
|
|
|
|
if DetermineImageType(buf) != JPEG {
|
|
t.Fatal("Image is not jpeg")
|
|
}
|
|
}
|
|
|
|
func TestWrite(t *testing.T) {
|
|
buf, err := Read("fixtures/test.jpg")
|
|
|
|
if err != nil {
|
|
t.Errorf("Cannot read the image: %#v", err)
|
|
}
|
|
|
|
if len(buf) == 0 {
|
|
t.Fatal("Empty buffer")
|
|
}
|
|
|
|
err = Write("fixtures/test_write_out.jpg", buf)
|
|
if err != nil {
|
|
t.Fatalf("Cannot write the file: %#v", err)
|
|
}
|
|
}
|