From 54468eb2c5c89da9ad28596dd8165d4cf3388459 Mon Sep 17 00:00:00 2001 From: Yonas Yanfa Date: Wed, 7 Aug 2024 08:06:27 -0400 Subject: [PATCH 1/3] feature (freebsd): PR #643 off master. (#731) Co-authored-by: Yonas --- server/plugin/plg_image_c/image_heif_freebsd.go | 11 +++++++++++ server/plugin/plg_image_c/image_heif_linux.go | 10 ++++++++++ server/plugin/plg_image_c/image_jpeg_freebsd.go | 11 +++++++++++ server/plugin/plg_image_c/image_jpeg_linux.go | 10 ++++++++++ server/plugin/plg_image_c/image_png_freebsd.go | 11 +++++++++++ server/plugin/plg_image_c/image_png_linux.go | 10 ++++++++++ server/plugin/plg_image_c/image_raw_freebsd.go | 11 +++++++++++ server/plugin/plg_image_c/image_raw_linux.go | 10 ++++++++++ 8 files changed, 84 insertions(+) create mode 100644 server/plugin/plg_image_c/image_heif_freebsd.go create mode 100644 server/plugin/plg_image_c/image_heif_linux.go create mode 100644 server/plugin/plg_image_c/image_jpeg_freebsd.go create mode 100644 server/plugin/plg_image_c/image_jpeg_linux.go create mode 100644 server/plugin/plg_image_c/image_png_freebsd.go create mode 100644 server/plugin/plg_image_c/image_png_linux.go create mode 100644 server/plugin/plg_image_c/image_raw_freebsd.go create mode 100644 server/plugin/plg_image_c/image_raw_linux.go diff --git a/server/plugin/plg_image_c/image_heif_freebsd.go b/server/plugin/plg_image_c/image_heif_freebsd.go new file mode 100644 index 00000000..c7a3e586 --- /dev/null +++ b/server/plugin/plg_image_c/image_heif_freebsd.go @@ -0,0 +1,11 @@ +package plg_image_c + +// #include "image_heif.h" +// #cgo LDFLAGS: -L /usr/local/lib -L /usr/lib -L /lib -lheif +// #cgo CFLAGS: -I /usr/local/include +import "C" + +func heif(input uintptr, output uintptr, size int) { + C.heif_to_jpeg(C.int(input), C.int(output), C.int(size)) + return +} diff --git a/server/plugin/plg_image_c/image_heif_linux.go b/server/plugin/plg_image_c/image_heif_linux.go new file mode 100644 index 00000000..95b6bced --- /dev/null +++ b/server/plugin/plg_image_c/image_heif_linux.go @@ -0,0 +1,10 @@ +package plg_image_c + +// #include "image_heif.h" +// #cgo LDFLAGS: -lheif +import "C" + +func heif(input uintptr, output uintptr, size int) { + C.heif_to_jpeg(C.int(input), C.int(output), C.int(size)) + return +} diff --git a/server/plugin/plg_image_c/image_jpeg_freebsd.go b/server/plugin/plg_image_c/image_jpeg_freebsd.go new file mode 100644 index 00000000..14c6879b --- /dev/null +++ b/server/plugin/plg_image_c/image_jpeg_freebsd.go @@ -0,0 +1,11 @@ +package plg_image_c + +// #include "image_jpeg.h" +// #cgo LDFLAGS: -L /usr/local/lib -L /usr/lib -L /lib -l:libjpeg.a +// #cgo CFLAGS: -I /usr/local/include +import "C" + +func jpeg(input uintptr, output uintptr, size int) { + C.jpeg_to_jpeg(C.int(input), C.int(output), C.int(size)) + return +} diff --git a/server/plugin/plg_image_c/image_jpeg_linux.go b/server/plugin/plg_image_c/image_jpeg_linux.go new file mode 100644 index 00000000..235e4139 --- /dev/null +++ b/server/plugin/plg_image_c/image_jpeg_linux.go @@ -0,0 +1,10 @@ +package plg_image_c + +// #include "image_jpeg.h" +// #cgo LDFLAGS: -l:libjpeg.a +import "C" + +func jpeg(input uintptr, output uintptr, size int) { + C.jpeg_to_jpeg(C.int(input), C.int(output), C.int(size)) + return +} diff --git a/server/plugin/plg_image_c/image_png_freebsd.go b/server/plugin/plg_image_c/image_png_freebsd.go new file mode 100644 index 00000000..22384c87 --- /dev/null +++ b/server/plugin/plg_image_c/image_png_freebsd.go @@ -0,0 +1,11 @@ +package plg_image_c + +// #include "image_png.h" +// #cgo LDFLAGS: -L /usr/local/lib -L /usr/lib -L /lib -l:libsharpyuv.a -l:libpng.a -l:libz.a -l:libwebp.a -l:libpthread.a -fopenmp +// #cgo CFLAGS: -I /usr/local/include +import "C" + +func png(input uintptr, output uintptr, size int) { + C.png_to_webp(C.int(input), C.int(output), C.int(size)) + return +} diff --git a/server/plugin/plg_image_c/image_png_linux.go b/server/plugin/plg_image_c/image_png_linux.go new file mode 100644 index 00000000..e87acdaf --- /dev/null +++ b/server/plugin/plg_image_c/image_png_linux.go @@ -0,0 +1,10 @@ +package plg_image_c + +// #include "image_png.h" +// #cgo LDFLAGS: -l:libpng.a -l:libz.a -l:libwebp.a -fopenmp +import "C" + +func png(input uintptr, output uintptr, size int) { + C.png_to_webp(C.int(input), C.int(output), C.int(size)) + return +} diff --git a/server/plugin/plg_image_c/image_raw_freebsd.go b/server/plugin/plg_image_c/image_raw_freebsd.go new file mode 100644 index 00000000..d95a667d --- /dev/null +++ b/server/plugin/plg_image_c/image_raw_freebsd.go @@ -0,0 +1,11 @@ +package plg_image_c + +// #include "image_raw.h" +// #cgo LDFLAGS: -L /usr/local/lib -L /usr/lib -L /lib -l:libyuv.a -l:libjpeg.a -l:libraw.a -fopenmp -l:libc++.a -llcms2 -lm +// #cgo CFLAGS: -I /usr/local/include +import "C" + +func raw(input uintptr, output uintptr, size int) { + C.raw_to_jpeg(C.int(input), C.int(output), C.int(size)) + return +} diff --git a/server/plugin/plg_image_c/image_raw_linux.go b/server/plugin/plg_image_c/image_raw_linux.go new file mode 100644 index 00000000..e9a0774f --- /dev/null +++ b/server/plugin/plg_image_c/image_raw_linux.go @@ -0,0 +1,10 @@ +package plg_image_c + +// #include "image_raw.h" +// #cgo LDFLAGS: -l:libjpeg.a -l:libraw.a -fopenmp -l:libstdc++.a -llcms2 -lm +import "C" + +func raw(input uintptr, output uintptr, size int) { + C.raw_to_jpeg(C.int(input), C.int(output), C.int(size)) + return +} From 3a8244912a7db610445a60654fa21ea94d7ad32a Mon Sep 17 00:00:00 2001 From: Peter Dave Hello Date: Wed, 7 Aug 2024 20:07:45 +0800 Subject: [PATCH 2/3] doc (README): readability - #721 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e1c04be7..c043506d 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ # The core idea Filestash started as an attempt to solve the Dropbox problem by abstracting the storage aspect so you can "bring your own backend" by implementing this interface: -``` +```go type IBackend interface { Init(params map[string]string, app *App) (IBackend, error) // constructor Ls(path string) ([]os.FileInfo, error) // list files in a folder From d30be7cfb663f5af2efee783cdbda94748f08cc8 Mon Sep 17 00:00:00 2001 From: zyAmo <126791274+zyAmo@users.noreply.github.com> Date: Wed, 7 Aug 2024 14:08:33 +0200 Subject: [PATCH 3/3] fix (#713): use input image colorspace for output image - #723 --- server/plugin/plg_image_c/image_jpeg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/plugin/plg_image_c/image_jpeg.c b/server/plugin/plg_image_c/image_jpeg.c index 7c4b91bf..5b118c2b 100644 --- a/server/plugin/plg_image_c/image_jpeg.c +++ b/server/plugin/plg_image_c/image_jpeg.c @@ -98,7 +98,7 @@ int jpeg_to_jpeg(int inputDesc, int outputDesc, int targetSize) { jpeg_config_output.image_width = jpeg_config_input.output_width; jpeg_config_output.image_height = jpeg_config_input.output_height; jpeg_config_output.input_components = jpeg_config_input.num_components; - jpeg_config_output.in_color_space = JCS_RGB; + jpeg_config_output.in_color_space = jpeg_config_input.out_color_space; jpeg_set_defaults(&jpeg_config_output); jpeg_set_quality(&jpeg_config_output, JPEG_QUALITY, TRUE); jpeg_start_compress(&jpeg_config_output, TRUE);