mirror of
https://github.com/mickael-kerjean/filestash
synced 2025-12-29 19:56:09 +01:00
fix (image): thumbnail generation for small images: libvips edge case - #93
This commit is contained in:
parent
bfacd4bcc5
commit
f561608a3c
3 changed files with 25 additions and 6 deletions
|
|
@ -21,6 +21,7 @@
|
|||
display: flex;
|
||||
flex-grow: 1;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
background: #525659;
|
||||
overflow: hidden;
|
||||
|
|
|
|||
|
|
@ -20,12 +20,23 @@ int resizer_process(const char *filename, void **buf, size_t *len, int size, int
|
|||
quality = quality > 100 || quality < 0 ? 80 : quality;
|
||||
exif = exif == 0 ? TRUE : FALSE;
|
||||
|
||||
err = vips_thumbnail(filename, &img, size,
|
||||
"size", VIPS_SIZE_DOWN,
|
||||
"auto_rotate", TRUE,
|
||||
"crop", crop,
|
||||
NULL
|
||||
);
|
||||
if(crop == VIPS_INTERESTING_CENTRE){
|
||||
// Generate a thumbnails: a square picture crop in the center
|
||||
err = vips_thumbnail(filename, &img, size,
|
||||
"size", VIPS_SIZE_BOTH,
|
||||
"auto_rotate", TRUE,
|
||||
"crop", VIPS_INTERESTING_CENTRE,
|
||||
NULL
|
||||
);
|
||||
}else{
|
||||
// normal resize of an image with libvips
|
||||
err = vips_thumbnail(filename, &img, size,
|
||||
"size", VIPS_SIZE_DOWN,
|
||||
"auto_rotate", TRUE,
|
||||
"crop", VIPS_INTERESTING_NONE,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
if(err != 0){
|
||||
return err;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,13 @@ func ProcessFileBeforeSend(reader io.Reader, ctx *App, req *http.Request, res *h
|
|||
(*res).Header().Set("Content-Type", mType)
|
||||
|
||||
if strings.HasPrefix(mType, "image/") {
|
||||
if mType == "image/svg" {
|
||||
(*res).Header().Set("Content-Type", "image/svg+xml")
|
||||
return reader, nil
|
||||
} else if mType == "image/x-icon" {
|
||||
return reader, nil
|
||||
}
|
||||
|
||||
if query.Get("thumbnail") != "true" && query.Get("size") == "" {
|
||||
return reader, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue