Knowing if background color was set

36 views
Skip to first unread message

lixo...@gmail.com

unread,
Oct 16, 2017, 8:47:22 PM10/16/17
to WebP Discussion
Is there a way to know if the background color was really set using the demux API?

I ask because

WebPDemuxGetI(WEBP_FF_BACKGROUND_COLOR)

will always succeed, so there is no way to know if the color I received was set by whomever created the image or if I just received the default value the library uses to initialize the struct.

I want to use that background color only if the author wanted to force a background for his image.

Pascal Massimino

unread,
Oct 17, 2017, 1:29:15 AM10/17/17
to WebP Discussion
Hi,

On Mon, Oct 16, 2017 at 5:47 PM, <lixo...@gmail.com> wrote:
Is there a way to know if the background color was really set using the demux API?

I ask because

WebPDemuxGetI(WEBP_FF_BACKGROUND_COLOR)

will always succeed, so there is no way to know if the color I received was set by whomever created the image or if I just received the default value the library uses to initialize the struct.

Background color is only relevant when ANIM chunk is present (= animation, with more than one frame).
See [1].
 

I want to use that background color only if the author wanted to force a background for his image.

For a single image, the background is always set to the default white color value.
For an animation, the background color is always set. So there's no way to know if it's been forced to a particular non-default value.

hope it helps,
skal/

lixo...@gmail.com

unread,
Oct 17, 2017, 12:41:57 PM10/17/17
to WebP Discussion
Got it. Two questions:

1.
Using WebPGetFeatures() and checking the WebPBitstreamFeatures::has_animation field should be enough, right?
If it is true I use the background color, otherwise I ignore it. Can I take this approach?

2.
I believe the confusion is due to the fact that I am relying on the Demux API to handle any WebP that cross my way.
It seems that it is able to deal with everything that I throw at it, which helps making my code simple. The only problem
so far is when I face fields like that, fields that only make sense when dealing with animations. So here is the second
question: can I do that? Can I always rely on the demux API for any WebP?


lixo...@gmail.com

unread,
Oct 17, 2017, 1:01:47 PM10/17/17
to WebP Discussion
Hummm
there seems to be an even better way to deal with my question #1:
using WebPDemuxGetI(..., WEBP_FF_FORMAT_FLAGS) and checking for WebPFeatureFlags::ANIMATION_FLAG


If that is correct I would like to suggest you guys to update the documentation on
WEBP_FF_FORMAT_FLAGS to indicate that, because just by looking at the docs on the
website or in the header it is impossible to figure that out. Only by digging into
the source I was able to see it.


Question #2 still stands.


Pascal Massimino

unread,
Oct 17, 2017, 1:15:35 PM10/17/17
to WebP Discussion
Hi,

On Tue, Oct 17, 2017 at 7:01 PM, <lixo...@gmail.com> wrote:
Hummm
there seems to be an even better way to deal with my question #1:
using WebPDemuxGetI(..., WEBP_FF_FORMAT_FLAGS) and checking for WebPFeatureFlags::ANIMATION_FLAG

Yes, that an equivalent way. And yes, WebPBitstreamFeatures::has_animation is for signalling animated WebP.


If that is correct I would like to suggest you guys to update the documentation on
WEBP_FF_FORMAT_FLAGS to indicate that, because just by looking at the docs on the
website or in the header it is impossible to figure that out. Only by digging into
the source I was able to see it.

Agreed.  demux.h:118 mentions that WEBP_FF_FORMAT_FLAGS will "return the flags present in the 'VP8X' chunk",
but it's not totally clear which flags. Will send a patch.



Question #2 still stands.

 
"Can I do that? Can I always rely on the demux API for any WebP?"

Yes, pretty much. The Demux API is meant to be able to parse (and detect errors) in any bitstream.

But the demux.h header could use an extra comment to document that WEBP_FF_BACKGROUND_COLOR
will only return a meaningful value in case the bitstream is an animated one.

hope it helps,
skal/

lixo...@gmail.com

unread,
Oct 17, 2017, 1:26:00 PM10/17/17
to WebP Discussion
Thanks!

Pascal Massimino

unread,
Oct 17, 2017, 2:00:20 PM10/17/17
to WebP Discussion


Comments welcome!

skal/

On Tue, Oct 17, 2017 at 10:25 AM, <lixo...@gmail.com> wrote:
Thanks!

--
You received this message because you are subscribed to the Google Groups "WebP Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webp-discuss+unsubscribe@webmproject.org.
To post to this group, send email to webp-d...@webmproject.org.
Visit this group at https://groups.google.com/a/webmproject.org/group/webp-discuss/.
For more options, visit https://groups.google.com/a/webmproject.org/d/optout.

Reply all
Reply to author
Forward
0 new messages