fix jpeg thumbnails
This commit is contained in:
4 files changed
+18
-10
No files matched your search
@@ -0,0 +1,6 @@
|
|||||||
|
Bugfix: Fix thumbnail generation for jpegs
|
||||||
|
|
||||||
|
Images with the extension `.jpeg` were not properly supported.
|
||||||
|
|
||||||
|
https://github.com/owncloud/ocis/issues/1490
|
||||||
|
https://github.com/owncloud/ocis/pull/1785
|
||||||
@@ -18,7 +18,6 @@ Other free text and markdown formatting can be used elsewhere in the document if
|
|||||||
- [webUIPreview/imageMediaViewer.feature:174](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIPreview/imageMediaViewer.feature#L174)
|
- [webUIPreview/imageMediaViewer.feature:174](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIPreview/imageMediaViewer.feature#L174)
|
||||||
|
|
||||||
### [Media Viewer preview not visible for files with .jpeg, .ogg, .webm and .gif formats](https://github.com/owncloud/ocis/issues/1490)
|
### [Media Viewer preview not visible for files with .jpeg, .ogg, .webm and .gif formats](https://github.com/owncloud/ocis/issues/1490)
|
||||||
- [webUIPreview/imageMediaViewer.feature:127](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIPreview/imageMediaViewer.feature#L127)
|
|
||||||
- [webUIPreview/imageMediaViewer.feature:136](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIPreview/imageMediaViewer.feature#L136)
|
- [webUIPreview/imageMediaViewer.feature:136](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIPreview/imageMediaViewer.feature#L136)
|
||||||
- [webUIPreview/imageMediaViewer.feature:145](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIPreview/imageMediaViewer.feature#L145)
|
- [webUIPreview/imageMediaViewer.feature:145](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIPreview/imageMediaViewer.feature#L145)
|
||||||
- [webUIPreview/imageMediaViewer.feature:154](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIPreview/imageMediaViewer.feature#L154)
|
- [webUIPreview/imageMediaViewer.feature:154](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIPreview/imageMediaViewer.feature#L154)
|
||||||
@@ -199,9 +198,6 @@ Other free text and markdown formatting can be used elsewhere in the document if
|
|||||||
### Image-Media-Viewer-Issue
|
### Image-Media-Viewer-Issue
|
||||||
- [webUIPreview/imageMediaViewer.feature:33](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIPreview/imageMediaViewer.feature#L33)
|
- [webUIPreview/imageMediaViewer.feature:33](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIPreview/imageMediaViewer.feature#L33)
|
||||||
|
|
||||||
### [media viewer does not display jpeg file](https://github.com/owncloud/web/issues/4296)
|
|
||||||
- [webUIPreview/imageMediaViewer.feature:15](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIPreview/imageMediaViewer.feature#L15)
|
|
||||||
|
|
||||||
### webUI-Private-Links
|
### webUI-Private-Links
|
||||||
- [webUIPrivateLinks/accessingPrivateLinks.feature:8](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIPrivateLinks/accessingPrivateLinks.feature#L8)
|
- [webUIPrivateLinks/accessingPrivateLinks.feature:8](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIPrivateLinks/accessingPrivateLinks.feature#L8)
|
||||||
- [webUIPrivateLinks/accessingPrivateLinks.feature:16](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIPrivateLinks/accessingPrivateLinks.feature#L16)
|
- [webUIPrivateLinks/accessingPrivateLinks.feature:16](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIPrivateLinks/accessingPrivateLinks.feature#L16)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ const (
|
|||||||
// Request combines all parameters provided when requesting a thumbnail
|
// Request combines all parameters provided when requesting a thumbnail
|
||||||
type Request struct {
|
type Request struct {
|
||||||
Filepath string
|
Filepath string
|
||||||
Filetype string
|
Extension string
|
||||||
Etag string
|
Etag string
|
||||||
Width int
|
Width int
|
||||||
Height int
|
Height int
|
||||||
@@ -50,7 +50,7 @@ func NewRequest(r *http.Request) (Request, error) {
|
|||||||
|
|
||||||
tr := Request{
|
tr := Request{
|
||||||
Filepath: path,
|
Filepath: path,
|
||||||
Filetype: strings.Replace(filepath.Ext(path), ".", "", 1),
|
Extension: filepath.Ext(path),
|
||||||
Etag: etag,
|
Etag: etag,
|
||||||
Width: width,
|
Width: width,
|
||||||
Height: height,
|
Height: height,
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ func (g Webdav) Thumbnail(w http.ResponseWriter, r *http.Request) {
|
|||||||
c := thumbnails.NewThumbnailService("com.owncloud.api.thumbnails", grpc.DefaultClient)
|
c := thumbnails.NewThumbnailService("com.owncloud.api.thumbnails", grpc.DefaultClient)
|
||||||
rsp, err := c.GetThumbnail(r.Context(), &thumbnails.GetRequest{
|
rsp, err := c.GetThumbnail(r.Context(), &thumbnails.GetRequest{
|
||||||
Filepath: strings.TrimLeft(tr.Filepath, "/"),
|
Filepath: strings.TrimLeft(tr.Filepath, "/"),
|
||||||
Filetype: extensionToFiletype(tr.Filetype),
|
Filetype: extensionToFiletype(strings.TrimLeft(tr.Extension, ".")),
|
||||||
Etag: tr.Etag,
|
Etag: tr.Etag,
|
||||||
Width: int32(tr.Width),
|
Width: int32(tr.Width),
|
||||||
Height: int32(tr.Height),
|
Height: int32(tr.Height),
|
||||||
@@ -90,11 +90,17 @@ func (g Webdav) Thumbnail(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func extensionToFiletype(ext string) thumbnails.GetRequest_FileType {
|
func extensionToFiletype(ext string) thumbnails.GetRequest_FileType {
|
||||||
val, ok := thumbnails.GetRequest_FileType_value[strings.ToUpper(ext)]
|
ext = strings.ToUpper(ext)
|
||||||
if !ok {
|
switch ext {
|
||||||
|
case "JPG", "PNG":
|
||||||
|
val := thumbnails.GetRequest_FileType_value[ext]
|
||||||
|
return thumbnails.GetRequest_FileType(val)
|
||||||
|
case "JPEG":
|
||||||
|
val := thumbnails.GetRequest_FileType_value["JPG"]
|
||||||
|
return thumbnails.GetRequest_FileType(val)
|
||||||
|
default:
|
||||||
return thumbnails.GetRequest_FileType(-1)
|
return thumbnails.GetRequest_FileType(-1)
|
||||||
}
|
}
|
||||||
return thumbnails.GetRequest_FileType(val)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func mustWrite(logger log.Logger, w io.Writer, val []byte) {
|
func mustWrite(logger log.Logger, w io.Writer, val []byte) {
|
||||||
|
|||||||
Reference in new issue
Block a user