Fix preview or viewing of shared animated GIFs (#6386)

* Fix preview or viewing of shared animated GIFs

---------

Co-authored-by: Roman Perekhod <rperekhod@owncloud.com>
This commit is contained in:
Roman Perekhod
2023-05-26 14:52:12 +02:00
committed by GitHub
co-authored by Roman Perekhod
parent 34909ec1fd
commit e57e6046d3
6 changed files with 144 additions and 38 deletions
@@ -104,6 +104,7 @@ func mapToStorageRequest(r Request) storage.Request {
}
}
// IsMimeTypeSupported validate if the mime type is supported
func IsMimeTypeSupported(m string) bool {
mimeType, _, err := mime.ParseMediaType(m)
if err != nil {
@@ -112,3 +113,22 @@ func IsMimeTypeSupported(m string) bool {
_, supported := SupportedMimeTypes[mimeType]
return supported
}
// PrepareRequest prepare the request based on image parameters
func PrepareRequest(width, height int, tType, checksum string) (Request, error) {
generator, err := GeneratorForType(tType)
if err != nil {
return Request{}, err
}
encoder, err := EncoderForType(tType)
if err != nil {
return Request{}, err
}
return Request{
Resolution: image.Rect(0, 0, width, height),
Generator: generator,
Encoder: encoder,
Checksum: checksum,
}, nil
}