Skip to content

WebP advanced output options - #569

Closed
smremde wants to merge 3 commits into
lovell:masterfrom
smremde:master
Closed

smremde wants to merge 3 commits into
lovell:masterfrom
smremde:master

Conversation

@smremde

@smremde smremde commented Sep 12, 2016

Copy link
Copy Markdown

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

lovell commented Sep 12, 2016

Copy link
Copy Markdown
Owner

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

dhotson commented Sep 12, 2016

Copy link
Copy Markdown

@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

smremde commented Sep 12, 2016

Copy link
Copy Markdown
Author

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

lovell commented Sep 12, 2016

Copy link
Copy Markdown
Owner

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

@jcupitt

jcupitt commented Sep 12, 2016

Copy link
Copy Markdown
Contributor

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

smremde commented Sep 12, 2016

Copy link
Copy Markdown
Author

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

@lovell

lovell commented Oct 22, 2016

Copy link
Copy Markdown
Owner

"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

lovell commented Nov 6, 2016

Copy link
Copy Markdown
Owner

"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

rn4391 commented Jan 11, 2017

Copy link
Copy Markdown

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

@lovell

lovell commented Jan 11, 2017 •

Copy link
Copy Markdown
Owner

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

@rn4391

rn4391 commented Jan 12, 2017 •

Copy link
Copy Markdown

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

lovell commented Jan 12, 2017

Copy link
Copy Markdown
Owner

@lovell

lovell commented Jan 19, 2017 •

Copy link
Copy Markdown
Owner

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