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

Poor compression from jpeg to avif via code #423

Closed
dAvagimyan opened this issue Apr 16, 2024 · 5 comments
Closed

Poor compression from jpeg to avif via code #423

dAvagimyan opened this issue Apr 16, 2024 · 5 comments

Comments

@dAvagimyan
Copy link
Contributor

Hi there! I'm using govips to convert jpg to avif. And I discovered that conversion from code works worse for me than conversion from the console. Could you help me figure it out? On large files the difference is 3 times. There is no such behavior with webp conversion

I tried effort with different values also with default cnf NewAvifExportParams()

size -> 1327450 -> cats.jpg - original
size ->1003222 -> cats.avif - via go code
size -> 404594 -> cats_inconsole.avif - via console (vips copy cats.jpg cats.avif )

It is golang code

inputImage, err := vips.NewImageFromFile("resources/cats.jpg")
	if err != nil {
		return err
	}
	defer inputImage.Close()
	if err := inputImage.OptimizeICCProfile(); err != nil {
		return err
	}

	ep := vips.NewAvifExportParams()
	ep.StripMetadata = true
	ep.Quality = 75
	ep.Effort = 1
	ep.Bitdepth = 8
	ep.Lossless = false

	imageBytes, _, err := inputImage.ExportAvif(ep)
	if err != nil {
		return err
	}

	_ = ioutil.WriteFile("cats.avif", imageBytes, 0644)

it is origin;
cats

@tonimelisma
Copy link
Collaborator

Hey @dAvagimyan, can you check what AVIF library your libvips build is built against, and check the latest libvips documentation for the parameters you can give? Sometimes we have stale parameters as libvips and/or the avif library libvips uses are updated and the govips API is out of date.

@dAvagimyan
Copy link
Contributor Author

vips version:
vips-8.15.1

 heif-enc --list-encoders
HEIC encoders:
AVIF encoders:
- aom = AOMedia Project AV1 Encoder 3.8.2-377-g04d6253 [default]
- svt = SVT-AV1 encoder v1.8.0
JPEG encoders:
- jpeg = libjpeg-turbo 1.2.90 (libjpeg 6.2) [default]
JPEG 2000 encoders:
Uncompressed encoders:
- uncompressed = uncompressed [default]

@tonimelisma
Copy link
Collaborator

Yes, could you look at libvips documentation for the parameters you can give? Sometimes the libvips backend has changed or the parameters and govips needs to be updated. Libvips has an impressive speed of development and backend libraries differ even between environments, it's very challenging to maintain govips APIs

@dAvagimyan
Copy link
Contributor Author

Thanks, I'll take a look. But I tried got it behavior in differents os. (centos 7, ubuntu, also macos)

@dAvagimyan
Copy link
Contributor Author

Everything is ok! Thanks a lot. Avif conversion in console using quality 50%.

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

2 participants