Skip to content
Snippets Groups Projects
Commit 84e2186f authored by Travis Ralston's avatar Travis Ralston
Browse files

Add TIFF thumbnail support

parent f9ff53d7
No related branches found
No related tags found
No related merge requests found
...@@ -91,6 +91,7 @@ path/server, for example, then you can simply update the path in the config for ...@@ -91,6 +91,7 @@ path/server, for example, then you can simply update the path in the config for
* Support for [MSC4034](https://github.com/matrix-org/matrix-spec-proposals/pull/4034) (self-serve usage information) is added, alongside a new "maximum file count" quota limit. * Support for [MSC4034](https://github.com/matrix-org/matrix-spec-proposals/pull/4034) (self-serve usage information) is added, alongside a new "maximum file count" quota limit.
* The `GET /_synapse/admin/v1/statistics/users/media` [endpoint](https://matrix-org.github.io/synapse/v1.88/admin_api/statistics.html#users-media-usage-statistics) from Synapse is now supported at the same path for local server admins. * The `GET /_synapse/admin/v1/statistics/users/media` [endpoint](https://matrix-org.github.io/synapse/v1.88/admin_api/statistics.html#users-media-usage-statistics) from Synapse is now supported at the same path for local server admins.
* Thumbnailing support for BMP images. * Thumbnailing support for BMP images.
* Thumbnailing support for TIFF images.
### Removed ### Removed
......
...@@ -412,6 +412,7 @@ thumbnails: ...@@ -412,6 +412,7 @@ thumbnails:
- "image/heif" - "image/heif"
- "image/webp" - "image/webp"
- "image/bmp" - "image/bmp"
- "image/tiff"
#- "image/svg+xml" # Be sure to have ImageMagick installed to thumbnail SVG files #- "image/svg+xml" # Be sure to have ImageMagick installed to thumbnail SVG files
- "audio/mpeg" - "audio/mpeg"
- "audio/ogg" - "audio/ogg"
......
package i
import (
"errors"
"io"
"github.com/turt2live/matrix-media-repo/common/rcontext"
"github.com/turt2live/matrix-media-repo/thumbnailing/m"
"golang.org/x/image/tiff"
)
type tiffGenerator struct {
}
func (d tiffGenerator) supportedContentTypes() []string {
return []string{"image/tiff"}
}
func (d tiffGenerator) supportsAnimation() bool {
return false
}
func (d tiffGenerator) matches(img io.Reader, contentType string) bool {
return contentType == "image/tiff"
}
func (d tiffGenerator) GetOriginDimensions(b io.Reader, contentType string, ctx rcontext.RequestContext) (bool, int, int, error) {
i, err := tiff.DecodeConfig(b)
if err != nil {
return false, 0, 0, err
}
return true, i.Width, i.Height, nil
}
func (d tiffGenerator) GenerateThumbnail(b io.Reader, contentType string, width int, height int, method string, animated bool, ctx rcontext.RequestContext) (*m.Thumbnail, error) {
src, err := tiff.Decode(b)
if err != nil {
return nil, errors.New("tiff: error decoding thumbnail: " + err.Error())
}
return pngGenerator{}.GenerateThumbnailOf(src, width, height, method, ctx)
}
func init() {
generators = append(generators, tiffGenerator{})
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment