From: Shotgun Thom on
First of all, the Quality Setting included in the code I posted is
only applied when saving a file as a JPEG. 75 is a reasonable setting
for quality of a JPEG image that's purpose is to be viewed on a
monitor. Good compression and reasonable quality. Get much lower
than that and you may begin to notice the image deterioration.

Regarding the PNG file size differences... it all has to do with
compression techniques. There are a bunch of tool/utilities
(PngCrush, PNGOUT, etc.) out there that do nothing but compress
existing PNG files. There's even an online site (www.punypng.com)
where you upload your PNG and it will reduce it for you and send it
back. Google PNG Compression Tools and you'll see the plethora of
choices.

The nice thing about all these compression tools is there, usually, is
no loss of image quality. The API code uses a pretty standard png
saving format. Other utilities/programs, obviously, have tweaked the
compression. Kinda like the difference between WinZip, GZip and 7Zip
compression. They are all Zip tools... just different compression.

Tom

From: Nando on
Shotgun Thom wrote:
> Regarding the PNG file size differences... it all has to do with
> compression techniques. There are a bunch of tool/utilities
> (PngCrush, PNGOUT, etc.) out there that do nothing but compress
> existing PNG files. There's even an online site (www.punypng.com)
> where you upload your PNG and it will reduce it for you and send it
> back. Google PNG Compression Tools and you'll see the plethora of
> choices.
>
> The nice thing about all these compression tools is there, usually, is
> no loss of image quality. The API code uses a pretty standard png
> saving format. Other utilities/programs, obviously, have tweaked the
> compression. Kinda like the difference between WinZip, GZip and 7Zip
> compression. They are all Zip tools... just different compression.

Very interesting stuff Tom! Great site too (punypng.com).

I'm not planning to work on this, but I must sort my curiosity here :-)
I'm not an expert in file formats, my understanding is based mostly in
the common idea that an electronic image is just that, a 3D matrix of
dots (x, y, color) with that info as part of the file's header.

However, if there are so many tools around that offer different
types/levels of lossless compressions (and the files are still
backward-compatible for displaying in browsers and old editors) then
that implies these tools must be injecting the PNG file with the
*actual* code/algorithm that decompresses the picture. Which leads me to
the idea of a security vulnerability (right?). I'm not getting paranoid,
only curious. Is this the way PNG images are crafted?
From: Jason Keats on
Nando wrote:
>
> I'm not planning to work on this, but I must sort my curiosity here :-)
> I'm not an expert in file formats, my understanding is based mostly in
> the common idea that an electronic image is just that, a 3D matrix of
> dots (x, y, color) with that info as part of the file's header.
>

Many image formats also have the capacity to store metadata, so that the
image is self describing - useful for archiving purposes.

http://www.steelbytes.com/?mid=30
for example, can strip such information from png/jpg files.

Perhaps the software you are using is also stripping that information -
because there is no standard way of adding such data to PNG files.
From: Mayayana on
A couple of side notes that might be useful:

* I'm not certain, but I think WIA is XP-only.

* If you look at planetsourcecode for Peter
Scale you'll find sample projects that provide
straight VB code for many graphic operations,
including not only "nearest neighbor" bilinear
resizing but also bicubic. (Though if I remember
correctly, starting with XP a basic StretchBLT
can use bicubic.)


| Interesting, I would like to try that (WIA Lib). Although I'm quite
| scare now, since I spent too much time already with another Microsoft
| library (GDI+) just to find out that it does not really do what I
| wanted. I'll look into WIA Lib, but with reserves.
|

| I'm not doing too much image manipulation in my app, just need to save a
| bitmap file to a 24-bit PNG file. I also needed to read the bitmap and
| create a new one setting DPI and resize it using basic
| "Nearest-Neighbor" interpolation. I had all that figured out and set up
| in my app using GDI+ (which until yesterday I never worked with). Now I
| have to start from scratch. Hopefully the Free Image Library will be
| more helpful.
|
| -Nando


From: Shotgun Thom on

Hi Nano...

Jason is correct in that most image formats can store metadata (EXIF)
information in the image. Here's an example of such informaion from a
typical .PNG:

File Name : balloonhotair.png
Directory : C:/iPic
File Size : 1571 kB
File Modification Date/Time : 2010:08:13 13:35:28-07:00
File Permissions : rw-rw-rw-
File Type : PNG
MIME Type : image/png
Image Width : 1024
Image Height : 768
Bit Depth : 8
Color Type : RGB
Compression : Deflate/Inflate
Filter : Adaptive
Interlace : Noninterlaced
SRGB Rendering : Perceptual
Gamma : 2.2
White Point X : 0.3127
White Point Y : 0.329
Red X : 0.64
Red Y : 0.33
Green X : 0.3
Green Y : 0.6
Blue X : 0.15
Blue Y : 0.06
Modify Date : 2002:10:07 10:06:47
Description :
Creation Time : 2002:10:05 07:34:53
Software : iQ ImageXpress
Source : CYBERSHOT
Image Size : 1024x768

This data is easily modified or can be deleted from virtually any PNG
image. I'm sure that would give some kind of size saving... just not
sure how much.

As far as security, I'm not sure what type of security, or
paranoia :) , you mean. Some photographers put copyright information
as part of image metadata so that could be tampered with.

Regarding Mayayana's post

A couple of side notes that might be useful:

> I'm not certain, but I think WIA is XP-only.

I think that is correct. While Win 7 has wiautt.dll pre-installed I
don't believe it's the same version 2.0. I know I tried using the
Printing features of WIA Ver 2.0 on Win 7 and it crapped out.



Tom