Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert png to jxl and the jxl image type is unknown #457

Open
cruvie opened this issue Nov 28, 2024 · 0 comments
Open

convert png to jxl and the jxl image type is unknown #457

cruvie opened this issue Nov 28, 2024 · 0 comments

Comments

@cruvie
Copy link

cruvie commented Nov 28, 2024

package examples

import (
	"bytes"
	"fmt"
	"gitee.com/cruvie/kk_go_kit/kk_file"
	"gitee.com/cruvie/kk_go_kit/kk_image"
	"github.com/davidbyttow/govips/v2/vips"
	"golang.org/x/sync/errgroup"
	"io"
	"log"
	"os"
	"sync"
	"testing"
	"time"
)

func TestBug(t *testing.T) {
	file, _ := os.Open("1111.png")
	buf, _ := io.ReadAll(file)
	importParams := vips.NewImportParams()
	inputImage, err := vips.LoadImageFromBuffer(buf, importParams)
	if err != nil {
		panic(err)
	}
	err = inputImage.AutoRotate()
	if err != nil {
		panic(err)
	}
	ep := vips.NewJxlExportParams()
	imageBytes, _, err := inputImage.ExportJxl(ep)
	if err != nil {
		panic(err)
	}
	out, _ := os.Create("testbug.jxl")
	io.Copy(out, bytes.NewReader(imageBytes))
	out.Close()
	//check image type
	filejxl, _ := os.Open("testbug.jxl")
	bufjxl, _ := io.ReadAll(filejxl)
	imageType := vips.DetermineImageType(bufjxl)
	log.Println(imageType == vips.ImageTypeUnknown)
}

go 1.23.2
govips v2.15.0

=== RUN   TestBug
2024/11/28 14:22:55 [VIPS.info] found /opt/homebrew/Cellar/vips/8.16.0/lib/vips-modules-8.16
2024/11/28 14:22:55 [VIPS.info] using configure-time prefix
2024/11/28 14:22:55 [VIPS.info] VIPS_PREFIX = /opt/homebrew/Cellar/vips/8.16.0
2024/11/28 14:22:55 [VIPS.info] VIPS_LIBDIR = /opt/homebrew/Cellar/vips/8.16.0/lib
2024/11/28 14:22:55 [VIPS.info] prefix = /opt/homebrew/Cellar/vips/8.16.0
2024/11/28 14:22:55 [VIPS.info] libdir = /opt/homebrew/Cellar/vips/8.16.0/lib
2024/11/28 14:22:55 [VIPS.info] searching "/opt/homebrew/Cellar/vips/8.16.0/lib/vips-modules-8.16"
2024/11/28 14:22:55 [VIPS.info] loading "/opt/homebrew/Cellar/vips/8.16.0/lib/vips-modules-8.16/vips-heif.dylib"
2024/11/28 14:22:55 [VIPS.info] loading "/opt/homebrew/Cellar/vips/8.16.0/lib/vips-modules-8.16/vips-magick.dylib"
2024/11/28 14:22:55 [VIPS.info] loading "/opt/homebrew/Cellar/vips/8.16.0/lib/vips-modules-8.16/vips-poppler.dylib"
2024/11/28 14:22:55 [VIPS.info] loading "/opt/homebrew/Cellar/vips/8.16.0/lib/vips-modules-8.16/vips-openslide.dylib"
2024/11/28 14:22:55 [VIPS.info] loading "/opt/homebrew/Cellar/vips/8.16.0/lib/vips-modules-8.16/vips-jxl.dylib"
2024/11/28 14:22:55 [VIPS.info] searching "/opt/homebrew/Cellar/vips/8.16.0/lib/vips-plugins-8.16"
2024/11/28 14:22:55 [VIPS.info] im_load_plugins: searching "/opt/homebrew/Cellar/vips/8.16.0/lib/vips-8.16"
2024/11/28 14:22:55 [VIPS.info] im_load_plugins: searching "/opt/homebrew/Cellar/vips/8.16.0/lib"
2024/11/28 14:22:55 [govips.info] vips 8.16.0 started with concurrency=1 cache_max_files=0 cache_max_mem=52428800 cache_max=100
2024/11/28 14:22:55 [govips.info] registered image type loader type=gif
2024/11/28 14:22:55 [govips.info] registered image type loader type=magick
2024/11/28 14:22:55 [govips.info] registered image type loader type=png
2024/11/28 14:22:55 [govips.info] registered image type loader type=tiff
2024/11/28 14:22:55 [govips.info] registered image type loader type=heif
2024/11/28 14:22:55 [govips.info] registered image type loader type=jp2k
2024/11/28 14:22:55 [govips.info] registered image type loader type=jxl
2024/11/28 14:22:55 [govips.info] registered image type loader type=jpeg
2024/11/28 14:22:55 [govips.info] registered image type loader type=pdf
2024/11/28 14:22:55 [govips.info] registered image type loader type=svg
2024/11/28 14:22:55 [govips.info] registered image type loader type=webp
2024/11/28 14:22:55 [govips.info] registered image type loader type=heif
2024/11/28 14:22:55 [VIPS.info] threadpool completed with 1 workers
2024/11/28 14:22:55 [VIPS.info] threadpool completed with 1 workers
2024/11/28 14:22:58 true
--- PASS: TestBug (2.73s)

归档.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant