Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

libpng / png_info questions

57 views
Skip to first unread message

Juha Nieminen

unread,
Oct 24, 2016, 4:53:05 AM10/24/16
to
I know, I know, this is not a question about the C++ language, but
a question about a library (and a C library at that). I know this is
a great faux pas. But the thing is, I would ask this in a relevant
group, or online forum, if there existed one. But as far as I can
gather, there is no such thing. There is no online forum for libpng
questions. (There is a mailing list yes, but this is not 1995 anymore,
mailing lists are a really antiquated and inconvenient form of
discussion, and I really am not willing to have my mail inbox be flooded
with irrelevant things because of this one question. It seems that
the libpng team is still living in 1995. Just look at their official
home page if you don't believe me.) There doesn't even seem to exist
a usenet group with the letters "png" in its name (at least not on
this news server).

So I was wondering if anybody here with expertise about libpng could
cast some light on this.

If I open a png file, do some modifications to its pixel data, and
then save it to another file, is there a way to transfer all metadata
from the input file to the output file? I'm assuming that all the
metadata is stored in the png_info struct, but according to the
documentation (in plain txt format; because we are still in 1995)
the png_info struct has to be created anew using a different png_struct
object for writing, than it was done for reading. I don't know if its
kosher to take the same png_info that was created for reading and use
it for writing.

The second question is how to make a copy of a png_info object.
I can't find any function to do that. (Since this is a C library,
not a C++ one, even if you could assign what png_infop points to,
to another instance, that would probably lead to leaks. But even
that's not possible because png_infop is an opaque pointer.)

--- news://freenews.netfront.net/ - complaints: ne...@netfront.net ---

Öö Tiib

unread,
Oct 24, 2016, 10:53:15 AM10/24/16
to
I think the "metadata" is something you write with 'png_write_chunk'
and handler function for that chunk during reading you set with
something like 'png_set_read_user_chunk_fn'

>
> The second question is how to make a copy of a png_info object.
> I can't find any function to do that. (Since this is a C library,
> not a C++ one, even if you could assign what png_infop points to,
> to another instance, that would probably lead to leaks. But even
> that's not possible because png_infop is an opaque pointer.)

AFAIK we create one for reading and other for writing and don't
copy those.

woodb...@gmail.com

unread,
Oct 24, 2016, 12:27:12 PM10/24/16
to
On Monday, October 24, 2016 at 3:53:05 AM UTC-5, Juha Nieminen wrote:
> I know, I know, this is not a question about the C++ language, but
> a question about a library (and a C library at that). I know this is
> a great faux pas. But the thing is, I would ask this in a relevant
> group, or online forum, if there existed one. But as far as I can
> gather, there is no such thing. There is no online forum for libpng
> questions. (There is a mailing list yes, but this is not 1995 anymore,
> mailing lists are a really antiquated and inconvenient form of
> discussion, and I really am not willing to have my mail inbox be flooded
> with irrelevant things because of this one question. It seems that
> the libpng team is still living in 1995. Just look at their official
> home page if you don't believe me.) There doesn't even seem to exist
> a usenet group with the letters "png" in its name (at least not on
> this news server).

Beggars can't be choosers. Their page looks good.

Brian
Ebenezer Enterprises - In G-d we trust.
http://webEbenezer.net

Jorgen Grahn

unread,
Oct 25, 2016, 5:18:49 AM10/25/16
to
On Mon, 2016-10-24, Juha Nieminen wrote:
...

> The second question is how to make a copy of a png_info object.
> I can't find any function to do that. (Since this is a C library,
> not a C++ one [...]

Isn't that one of the most common problems with C libraries, when used
by C++ people? They include everything else, but forget that feature,
and our client code becomes a bit crippled.

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .

Richard

unread,
Oct 25, 2016, 1:43:13 PM10/25/16
to
[Please do not mail me a copy of your followup]

Jorgen Grahn <grahn...@snipabacken.se> spake the secret code
<slrno0u8r9.5...@frailea.sa.invalid> thusly:

>On Mon, 2016-10-24, Juha Nieminen wrote:
>...
>
>> The second question is how to make a copy of a png_info object.
>> I can't find any function to do that. (Since this is a C library,
>> not a C++ one [...]
>
>Isn't that one of the most common problems with C libraries, when used
>by C++ people? They include everything else, but forget that feature,
>and our client code becomes a bit crippled.

Did you consider that they didn't "forget" the feature, but they never
intended for you to copy these structures?
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Terminals Wiki <http://terminals-wiki.org>
The Computer Graphics Museum <http://computergraphicsmuseum.org>
Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>

Jorgen Grahn

unread,
Oct 26, 2016, 2:30:34 AM10/26/16
to
On Tue, 2016-10-25, Richard wrote:
> [Please do not mail me a copy of your followup]
>
> Jorgen Grahn <grahn...@snipabacken.se> spake the secret code
> <slrno0u8r9.5...@frailea.sa.invalid> thusly:
>
>>On Mon, 2016-10-24, Juha Nieminen wrote:
>>...
>>
>>> The second question is how to make a copy of a png_info object.
>>> I can't find any function to do that. (Since this is a C library,
>>> not a C++ one [...]
>>
>>Isn't that one of the most common problems with C libraries, when used
>>by C++ people? They include everything else, but forget that feature,
>>and our client code becomes a bit crippled.
>
> Did you consider that they didn't "forget" the feature, but they never
> intended for you to copy these structures?

If it's useful and feasible to copy them (like it must have been for
Juha) why not allow it?

Juha Nieminen

unread,
Oct 26, 2016, 3:11:15 AM10/26/16
to
Richard <legaliz...@mail.xmission.com> wrote:
>>Isn't that one of the most common problems with C libraries, when used
>>by C++ people? They include everything else, but forget that feature,
>>and our client code becomes a bit crippled.
>
> Did you consider that they didn't "forget" the feature, but they never
> intended for you to copy these structures?

From what I gather (although it's hard to wade through their documentation
because it's one flat plaintext .txt file with no formatting of any kind,
not even in the form of ascii bulletpoints (eg. using asterisks) or anything
of the sort) there doesn't seem to be any way of semi-automatically transfer
all the metadata from an input png file to an output one (so that it's all
preserved as-is, when all you want is to, for example, just modify the
pixel data in some manner, but have everything else preserved).
As a consequence, there isn't any way to automatically copy all that
metadata to multiple output files.

There may be many other reasons why you want to just copy the metadata
in your program. But there doesn't seem to be any way of doing this that
I can see.

The metadata doesn't only include any user-defined content, but also
gamma information, pixel offsets, and any other such information that
may exist in the metadata of the png file.

One could think that copying stuff around would be one of the most
fundamental features of such a library, but apparently not.

Richard

unread,
Oct 26, 2016, 12:10:32 PM10/26/16
to
[Please do not mail me a copy of your followup]

Jorgen Grahn <grahn...@snipabacken.se> spake the secret code
<slrno10jbv.5...@frailea.sa.invalid> thusly:
Take note that you had to conditionalize your question.

I've used libpng lots of times (and so have many, many, many other
libraries and applications) and have never needed or wanted to copy
those structures.

Ask yourself why so many libraries and applications have used this
library and never needed to do this?

Öö Tiib

unread,
Oct 26, 2016, 12:48:38 PM10/26/16
to
Depends perhaps for what you need it but someone may be has already
made some C++ classes for manipulating PNG files and published these.
For example that library looks like one: http://freeimage.sourceforge.net/

Juha Nieminen

unread,
Oct 27, 2016, 2:17:26 AM10/27/16
to
Öö Tiib <oot...@hot.ee> wrote:
> Depends perhaps for what you need it but someone may be has already
> made some C++ classes for manipulating PNG files and published these.
> For example that library looks like one: http://freeimage.sourceforge.net/

If I'm developing a libpng wrapper, I'm not going to use someone else's
wrapper.
0 new messages