Where is the code for handling libpng for displaying ᴘɴɢ image inside webpages ?

26 views
Skip to first unread message

lael.c...@gmail.com

unread,
Dec 12, 2017, 3:22:36 PM12/12/17
to Chromium-dev
Hello,

for viewing ᴘɴɢ image inside an ʜᴛᴍʟ page, chromium/chrome do it through libwebp, isn’t it ?

Lei Zhang

unread,
Dec 12, 2017, 4:33:52 PM12/12/17
to lael.c...@gmail.com, Chromium-dev
No, WebP is a different image format from PNG. Very very likely, PNG
images are processed with libpng.
> --
> --
> Chromium Developers mailing list: chromi...@chromium.org
> View archives, change email options, or unsubscribe:
> http://groups.google.com/a/chromium.org/group/chromium-dev
> ---
> You received this message because you are subscribed to the Google Groups
> "Chromium-dev" group.
> To view this discussion on the web visit
> https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/b336a3d2-685e-47e6-97bc-9c9a530ed4eb%40chromium.org.

lael.c...@gmail.com

unread,
Dec 12, 2017, 5:00:24 PM12/12/17
to Chromium-dev, lael.c...@gmail.com
No, I mean that the only place where <png.h> in included outside pdfium and libpng is libwebp. (libwebp itself use libpng for png processing).

So does chrome/chromium uses libwebp for ᴘɴɢ image processing ? (converting all formats to webp internally)

Torne (Richard Coles)

unread,
Dec 12, 2017, 6:44:12 PM12/12/17
to lael.c...@gmail.com, Chromium-dev
Chromium doesn't use system libraries for most things, so there are no includes of <png.h> (the place where that occurs in libwebp is not actually used in chromium).

There's a copy of libpng in third_party/libpng, so the files which include that include "third_party/libpng/png.h", and you're probably looking for ui/gfx/codec/png_codec.cc ?

Peter Kasting

unread,
Dec 12, 2017, 6:48:50 PM12/12/17
to lael.c...@gmail.com, Chromium-dev
On Tue, Dec 12, 2017 at 12:22 PM, <lael.c...@gmail.com> wrote:
Hello,

for viewing ᴘɴɢ image inside an ʜᴛᴍʟ page, chromium/chrome do it through libwebp, isn’t it ?

No.


The chain of #includes to png.h is PNGImageDecoder.h -> PNGImageReader.h -> png.h.

PK

Khushal Sagar

unread,
Dec 12, 2017, 6:49:20 PM12/12/17
to to...@chromium.org, lael.c...@gmail.com, Chromium-dev
Blink has it's own image decoders for most formats, some of which have been switched to use skia. You're looking for https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platform/image-decoders/png/ for png.

lael.c...@gmail.com

unread,
Dec 12, 2017, 6:52:55 PM12/12/17
to Chromium-dev, lael.c...@gmail.com

Yes, except, there’s an option for building chromium with system libpng instead of provided libpng (that’s how in many Linux distribution chromium packages requires the libpng like in Fedora).

This is done everywhere through a compile define which triggers the :

#include <png.h>

compiler macro

lael.c...@gmail.com

unread,
Dec 12, 2017, 6:53:45 PM12/12/17
to Chromium-dev, to...@chromium.org, lael.c...@gmail.com
Thank you,
Are there plans to switch libpng handling to skia ?

Peter Kasting

unread,
Dec 12, 2017, 6:56:04 PM12/12/17
to lael.c...@gmail.com, Chromium-dev
On Tue, Dec 12, 2017 at 3:52 PM, <lael.c...@gmail.com> wrote:

Yes, except, there’s an option for building chromium with system libpng instead of provided libpng (that’s how in many Linux distribution chromium packages requires the libpng like in Fedora).

I would assume that maps the include/link directories so that "png.h" is pulled from the system locations.

If instead of leaving us context-free you gave some background on what you're really trying to do/figure out, it would help to guide you better.

PK

Torne (Richard Coles)

unread,
Dec 12, 2017, 7:00:30 PM12/12/17
to lael.c...@gmail.com, Chromium-dev
No, that's not how it works in Chromium. Unbundled system library support is provided by the files in build/linux/unbundle, which generate shim headers in a special location that is still available as "third_party/libpng/png.h" that in turn include <png.h> from the system. These are generated at build time when using the unbundle scripts, so you won't find them in the sources.

So, regardless of whether the system libpng is in use, the relevant include is still "third_party/libpng/png.h".

The ifdefs you've found are how pdfium handles this, which is separate.

lael.c...@gmail.com

unread,
Dec 12, 2017, 7:04:48 PM12/12/17
to Chromium-dev, lael.c...@gmail.com
I’m trying to write a libpng fuzzer that would immitate webkit handling of libpng along additional checksums disabling than what libfuzzer is currently doing with png_set_crc_actions. (so instead of fuzzing libpng, I want to fuzz libpng through webkit) 

PK

lael.c...@gmail.com

unread,
Dec 12, 2017, 7:37:27 PM12/12/17
to Chromium-dev, Peter Kasting

I’m trying to write a libpng fuzzer that would use Webkit’s PNGImageDecoder  along additional checksums disabling than what libfuzzer is currently doing with png_set_crc_action(). (so instead of fuzzing libpng, I want to fuzz libpng through the PNGImageDecoder class) 

Le mercredi 13 décembre 2017 00:56:04 UTC+1, Peter Kasting a écrit :

Noel Gordon

unread,
Dec 13, 2017, 1:05:44 AM12/13/17
to Chromium-dev, pkas...@chromium.org
https://cs.chromium.org/search/?q=png+fuzzer&type=cs for examples of how we fuzz PNGImageDecoder and so on.

~noel
Reply all
Reply to author
Forward
0 new messages