[quote author="Tobias Hunger" date="1316772194"]Lukas: You are right. The first can be solved by doing the image-loading and conversion-to-png that the code is doing actually doing. So those conversions are not completely useless. [/quote]
Actually, I would not assume that an image save in format A and in format B will be exactly the same anymore after loading and decoding them again, unless it was explictly clear that the formats are lossless. The format most often used (and used in the sample code from harshita) to store pictures (.jpg) is not. So even for that case, it is useless.
Anyway, I think Lukas pointed at an excellent starting point for this in the slashdot. I am actually quite interested in this myself, as I have some ideas for an application that would need to use this functionality too.