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

WebP advanced output options #569

Closed
wants to merge 3 commits into from
Closed

WebP advanced output options #569

wants to merge 3 commits into from

Conversation

smremde
Copy link

@smremde smremde commented Sep 12, 2016

Please see this pull request for three additional WebP output option: lossless, alpha_q and near_lossless. See http://www.vips.ecs.soton.ac.uk/supported/8.3/doc/html/libvips/VipsForeignSave.html#vips-webpsave-buffer

I am having trouble getting near_lossless and alpha_q working

vips warning: webpsave_buffer: no property named `near_lossless'
vips warning: webpsave_buffer: no property named `alpha_q'

The version of libvips downloaded is 8.3.3 so I'm not sure why these are not working - any advice?

I have added documentation and a simple unit test for alpha_q, which should pass when this property can be set. I'll add unit tests for the other parameters after.

@lovell
Copy link
Owner

lovell commented Sep 12, 2016

Hi Stephen, thank you for this PR.

The new WebP options will be in the forthcoming libvips v8.4.0, hence the errors. I expect the future sharp v0.17.0 to have a dependency on libvips v8.4.x.

In terms of the API, rather than the existing method-per-option approach, I'd like to start moving any format-specific options into a method specific to that format (e.g. webp({nearLossless: true})). Given the output format may not be known until the input has been read, this might also require a single method that accepts an Object of options for many formats.

I realise this is a much wider change than just the new WebP options here, but this PR feels like a good place to start.

Let me have a go at moving the JPEG-specific withoutChromaSubsampling first (with a deprecation route) to explore how the API could behave.

/cc @dhotson who may be interested in these options also - see #408

@dhotson
Copy link

dhotson commented Sep 12, 2016

@lovell @smremde Ah this is brilliant! It's great to see support for these options. 😄

I've been keeping a branch with just basic lossless support: master...dhotson:webp-save-lossless

.. the project I was working on got delayed so I never got around to finishing it off with proper tests and docs etc sorry. Thank you very much @smremde for taking the initiative on this PR. 😄

For what it's worth—I think I agree that it makes sense to have format specific options as params, rather than separate methods. 👍

@smremde
Copy link
Author

smremde commented Sep 12, 2016

I am confused about alpha_q and near_lossless. The libvips documentation suggests this is in 8.3 as per the link I sent. Checking git, it appears that the documentation is wrong on this one.

Yes I agree, per format options would be much better. I'll watch this PR and can update it once you have explored the best way of doing this.

@lovell
Copy link
Owner

lovell commented Sep 12, 2016

@jcupitt Could the libvips 8.3 published docs have been generated from 8.4 source?

@jcupitt
Copy link
Contributor

jcupitt commented Sep 12, 2016

Oh dear, I'm very sorry, these are 8.4 options.

The 8.3 docs had a number of serious issues (whole sections missing, broken cross-referencing, argh) and I spent ages fixing up doc generation for 8.4. The poor 8.3 docs were causing people quite a few problems, so I put the much better 8.4 docs up instead. I hoped that the win from having working docs outweighed the confusion of having a few features which didn't actually exist.

8.4 should be out within the next week, so this problem will vanish. I hope I didn't waste too much of your time.

@smremde
Copy link
Author

smremde commented Sep 12, 2016

@jcupitt Not at all. This PR should work with little or no modification once sharp upgrades to 8.4 I assume.

@lovell
Copy link
Owner

lovell commented Oct 22, 2016

"Let me have a go at moving the JPEG-specific withoutChromaSubsampling first (with a deprecation route) to explore how the API could behave."

See commit 1159c99 for the first part of the groundwork for this.

@lovell
Copy link
Owner

lovell commented Nov 6, 2016

"In terms of the API, rather than the existing method-per-option approach, I'd like to start moving any format-specific options into a method specific to that format (e.g. webp({nearLossless: true})). "

This approach, with complete JSDoc comments, is now available in the master branch when setting output options.

https://github.com/lovell/sharp/blob/master/lib/output.js

Functions relevant to this PR are webp(), the _setBooleanOption() helper and the is.* type-checkers.

@rn4391
Copy link

rn4391 commented Jan 11, 2017

Is this feature merged through some other PR? If not, then can I take this up to fit into the new API?

@lovell
Copy link
Owner

lovell commented Jan 11, 2017

@RNanwani This is not merged yet so an alternative PR would be welcome, thank you.

@rn4391
Copy link

rn4391 commented Jan 12, 2017

Can you confirm if this is the right command to test vips near lossless flag

vips copy test/fixtures/alpha-premultiply-1024x768-paper.png /tmp/webp-near-lossless-20.webp[near_lossless,Q=20]

@lovell
Copy link
Owner

lovell commented Jan 12, 2017

@RNanwani Yes, near_lossless is the relevant flag - see also https://github.com/jcupitt/libvips/pull/430

@lovell
Copy link
Owner

lovell commented Jan 19, 2017

Superseded by #685. Thank you for the original inspiration and work on this everyone.

@lovell lovell closed this Jan 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants