Discussion:
[Bitpim-devel] png conversion helper tool
d***@netzero.com
2005-01-03 17:48:17 UTC
Permalink
I'd like to add and use an open source png tool called 'pngrewrite' to convert 32-bit png image files to 8-bit palletized image files. Currenlty, Windows binary is available, and the author stated that the source should compile readily for Linux (it requires libpng and libz). It is similar to the tools Stephen uses in his conversions routine but offers other advantages:

1. One pass conversion operation (pngrewrite <input file> <output file>)
2. Minimize, palletize, and preserve the same number of colors from the original image.

I did some preliminary integration and testing with BITPIM, and the tool seems to work well.

-Joe Pham


________________________________________________________________
NetZero Gift Certificates
Give the gift of Internet access this holiday season.
http://www.netzero.com/give
Roger Binns
2005-01-03 20:14:42 UTC
Permalink
There is no way we can redistribute source or binary for other components unless
they have *very* clear licensing and copyright information. The author appears
to sort of made it public domain without actually doing so in the correct way.
Post by d***@netzero.com
I'd like to add and use an open source png tool called 'pngrewrite' to convert
32-bit png image files to 8-bit palletized image files.
What is wrong with what we already have (netpbm)?

The advantage of the netpbm stuff is that it has a large number of conversions
and filters, and we have working binaries for all platforms.
Post by d***@netzero.com
1. One pass conversion operation (pngrewrite <input file> <output file>)
This isn't that big a deal. Having multiple tools lets us glue together
the series of transformations we want. The worst case is Windows where making
new processes is relatively more expensive, but I don't see this as a big
issue especially losing the flexibility of multiple components.

(And in the case of the conversions code, we could have supplied the pnm format
directly rather than the png data reducing the number of conversions by one.)
Post by d***@netzero.com
2. Minimize, palletize, and preserve the same number of colors from the original image.
The wxWidgets code uses the latest libpng.
d***@netzero.com
2005-01-03 23:03:14 UTC
Permalink
There is no way we can redistribute source or binary for other >components unless they have *very* clear licensing and copyright >information.
That's why I asked the question to make sure all bases are covered.
Post by d***@netzero.com
1. One pass conversion operation (pngrewrite <input file> <output file>)
This isn't that big a deal.
Just a fringe benefit anyway; that alone does not warrant the use of the tool.
For 8 bit palletized PNGs, are you sure that the netpbm program is >doing a bad job?
On the contrary, based on the number of images that I tried, it did very well. My only nitpick with it is that it seems to do a balancing act between the # of colors and the file size, which I think is what Stephend originally intended. Addtionally, it also seems to always do the conversion, which's probably part of the original goals. What I'd like to have, if possible, is to preserve the # of color and create/convert into a smallest possible file, which may include doing nothing. I guess you could say it's the case of 'better is the enemy of good enough' :-)

-Joe Pham



________________________________________________________________
NetZero Gift Certificates
Give the gift of Internet access this holiday season.
http://www.netzero.com/give
Roger Binns
2005-01-04 00:11:05 UTC
Permalink
Post by d***@netzero.com
On the contrary, based on the number of images that I tried,
it did very well. My only nitpick with it is that it seems to
do a balancing act between the # of colors and the file size,
which I think is what Stephend originally intended.
Yes, that is exactly what that function does. It gets you the best
possible 8 bit png that fits within the specified file size.

What isn't clear is what your goals are. If you just want a straight
forward conversion to 8 bit png then just pass in a really large size
for the maxsize. (Ideally there should be two functions - one to do
the size constrained conversion and one just to do the conversion.)
Post by d***@netzero.com
What I'd like to have, if possible, is to preserve the # of color and
create/convert into a smallest possible file, which may include doing
nothing.
As far as I can tell wxWidgets always saves png images as 24 bit. It
seems like your issue is that sometimes the original image has less
than 256 distinct colours and you would rather those are saved as
8 bit because the file is smaller (how much smaller exactly?)

The solution to this is trivial and should be put in a function in
conversions.

- Use wxImage.ComputeHistogram to count the number of colours. If
more than 256 then use wxImage.SaveFile to save it.

- If less than or equal to 256 then use the existing
conversions.convertto8bitpng to save it out.

Hopefully wxWidgets will support 8bit saving natively in the future at
which point we make the above function trivial. I just double checked
the 2.5.3.1 wxWidgets source and I doesn't support 8 bit saving. Consequently
I entered a feature request at SF:

http://sf.net/tracker/index.php?func=detail&aid=1095385&group_id=9863&atid=359863

Roger
d***@netzero.com
2005-01-04 00:49:31 UTC
Permalink
Post by Roger Binns
The solution to this is trivial and should be put in a function in
conversions.
It is trivial once you pointed it out :-)

Weekly build tonight ??

-Joe Pham



________________________________________________________________
NetZero Gift Certificates
Give the gift of Internet access this holiday season.
http://www.netzero.com/give
Roger Binns
2005-01-04 01:03:41 UTC
Permalink
Post by d***@netzero.com
It is trivial once you pointed it out :-)
All things become trivial once you have to explain to someone else how
non-trivial something is :-)
Post by d***@netzero.com
Weekly build tonight ??
I will be comitting the new ringtone and wallpaper code this evening.
Consequently the build will be tomorrow night so the bugs can be found
and fixed :-)

Roger

Loading...