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

Change Chroma Subsample for Image files #538

Closed
sachin-walia opened this issue Oct 14, 2016 · 4 comments
Closed

Change Chroma Subsample for Image files #538

sachin-walia opened this issue Oct 14, 2016 · 4 comments

Comments

@sachin-walia
Copy link

Is there a setting in vips jpegsave that allows to change chroma subsampling of input images. For web use I think the recommended setting is 4:2:0 or 2x2.

thanks.

@jcupitt
Copy link
Member

jcupitt commented Oct 14, 2016

For jpeg write it's just on or off. I'll tag this as an ehancement.

Edit: default (4:2:0) or off, I should say.

@sachin-walia
Copy link
Author

Thanks @jcupitt for the prompt response. Is it possible to support it the way GraphicsMagick does:

http://www.graphicsmagick.org/GraphicsMagick.html#details-sampling-factor

Typically if you take screenshot or framegrab from the video sources they may come with subsampling as 4:4:4 and I think it may make sense to provide at least following options:

  1. 4:4:4 (or no subsampling)
  2. downsample to 4:2:2
  3. downsample to most popular 4:2:0

thanks.

@jcupitt
Copy link
Member

jcupitt commented Jan 20, 2017

Looking at the definition of the subsampling notation here:

http://www.poynton.com/PDFs/Chroma_subsampling_notation.pdf

Current libvips behaviour is:

  • vips copy x.png x.jpg[Q=80] below Q90, libvips will write 4:2:0, ie. 2:1 horizontal and vertical subsampling of Cr and Cb, the jpeg standard.
  • vips copy x.png x.jpg[Q=95] above Q90, libvips will write 4:4:4, ie. no subsampling of Cr and Cb, following ImageMagick's practice.
  • vips copy x.png x.jpg[Q=80,no-subsample] overrides the automatic enabling of subsample and will write 4:4:4.

You can't write Q > 90 and subsample, but that must be rather rare, I think.

It doesn't seem that easy to add all these options, especially the offset chroma you need for 4:2:2. Could you explain the use case?

@jcupitt
Copy link
Member

jcupitt commented Jul 11, 2020

From 8.9 there is a subsample-mode option to jpegsave. You can set it on, off or auto. In auto mode, chroma subsample is disabled if Q is 90 or more. The default mode is auto.

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

No branches or pull requests

2 participants