diff --git a/server/router/api/v1/attachment_service.go b/server/router/api/v1/attachment_service.go index 7eefecec8..fec4b878c 100644 --- a/server/router/api/v1/attachment_service.go +++ b/server/router/api/v1/attachment_service.go @@ -6,8 +6,6 @@ import ( "encoding/binary" "fmt" "image" - _ "image/jpeg" - _ "image/png" "io" "log/slog" "os" @@ -549,7 +547,9 @@ func downscaleImage(imageBlob []byte, maxDimension int, quality int) ([]byte, er } // Reset reader position for actual decoding - reader.Seek(0, 0) + if _, err := reader.Seek(0, 0); err != nil { + return nil, errors.Wrap(err, "failed to reset reader position") + } // Decode the image with auto-orientation support img, err := imaging.Decode(reader, imaging.AutoOrientation(true)) @@ -574,9 +574,8 @@ func downscaleImage(imageBlob []byte, maxDimension int, quality int) ([]byte, er targetHeight = maxDimension } } else { - // Keep original dimensions for small images - targetWidth = width - targetHeight = height + // Do not modify small images + return imageBlob, nil } // Resize the image to the calculated dimensions diff --git a/web/src/components/Settings/StorageSection.tsx b/web/src/components/Settings/StorageSection.tsx index cc0cbcc72..07ef8c4fb 100644 --- a/web/src/components/Settings/StorageSection.tsx +++ b/web/src/components/Settings/StorageSection.tsx @@ -43,13 +43,13 @@ const StorageSection = observer(() => { if (workspaceStorageSetting.imageMaxSize < 0) { return false; } - if (workspaceStorageSetting.jpegQuality <= 0 || workspaceStorageSetting.jpegQuality > 100) { + if (workspaceStorageSetting.jpegQuality < 1 || workspaceStorageSetting.jpegQuality > 100) { return false; } if (workspaceStorageSetting.thumbnailMaxSize <= 0) { return false; } - if (workspaceStorageSetting.thumbnailJpegQuality <= 0 || workspaceStorageSetting.thumbnailJpegQuality > 100) { + if (workspaceStorageSetting.thumbnailJpegQuality < 1 || workspaceStorageSetting.thumbnailJpegQuality > 100) { return false; } @@ -301,7 +301,7 @@ const StorageSection = observer(() => { )} - +
Maximum image size (px) @@ -311,7 +311,10 @@ const StorageSection = observer(() => { -

Maximum size in pixels for the largest dimension when storing images. Images larger than this will be downscaled. Set to 0 to disable downscaling (default: 0, no downscaling).

+

+ Maximum size in pixels for the largest dimension when storing images. Images larger than this will be downscaled. Set to 0 + to disable downscaling (default: 0, no downscaling). +

@@ -327,7 +330,10 @@ const StorageSection = observer(() => { -

JPEG quality (0-100) used when downscaling uploaded images. Higher values = better quality but larger file size (default: 85).

+

+ JPEG quality (0-100) used when downscaling uploaded images. Higher values = better quality but larger file size (default: + 85). +

@@ -364,7 +370,11 @@ const StorageSection = observer(() => {
- +