JPG - PNG conversion problem
Raaijmakers, Vincent (GE Infrastructure)
Vincent.Raaijmakers at ge.com
Tue Feb 3 21:57:06 CET 2004
The 64k is measured as a size in memory, not on disk
This is how I measured the size:
blob = Blob()
image = Image("foo.jpg")
image.magick = "PNG"
image.depth = 8
In my case, the data has to be "streamed" to another desktop, for that reason I use Blob here.
(Actualy, when I write the image to disk, still the same size...)
Why PNG....., I have to. The application that needs my processed images only accepts PNG. No control over that.
I know, pretty poor, but that is just the fact.
So my hope is that the way how I do the coversion in Magick is wrong. Just hoping for someone who discovered the same issue and knows the solution!
From: python-list-bounces+vincent.raaijmakers=ge.com at python.org
[mailto:python-list-bounces+vincent.raaijmakers=ge.com at python.org]On
Behalf Of Dietrich Epp
Sent: Monday, February 02, 2004 9:14 PM
To: Python List
Subject: Re: JPG - PNG conversion problem
On Feb 2, 2004, at 9:32 AM, Raaijmakers, Vincent ((GE Infrastructure))
> Yes I did.
> image.depth = 8
> But it didn't help, the 64k is the image file size having 256 colors.
160 * 120 = 19200
So something is wrong. First of all, PNG compressions is usually
around 2:1 to 4:1. JPG compression often still looks acceptable at
10:1 or higher. Second of all, depth is bits per sample. 8-bit RGB
takes up 24 bits per pixel. The depth is probably 8 already. What you
want to do is convert the image to indexed color.
My guess is the reason your file takes up 64k on your hard drive is
that your file system is rounding up to the nearest block. Try to find
out the exact number of bytes, it's undoubtedly smaller. Create a text
file on your drive that only contains one letter, then tell us what the
size is. Due to the type of compression that PNG uses, the worst case
scenario is a little more than 57k.
Now comes the part where I question your motives... what is wrong with
JPEG? Converting JPEG to PNG indexed is practically the worst case
scenario for image conversion. You get big file sizes, dithering, and
JPEG artifacts all in one image! I can think of worse conversions, but
they involve things like transmitting the raw image data over an RS232
connection without error connection up an elevator shaft.
More information about the Python-list