JPG - PNG conversion problem

Raaijmakers, Vincent (GE Infrastructure) Vincent.Raaijmakers at ge.com
Mon Jan 26 09:01:33 EST 2004


Who can explain the huge increase in size when I convert a JPG into a PNG format using PythonMagick:
I read the JPG from a video server and has a resolution of 352x240, size is about 15k
After my PNG conversion and resizing the resolution to 160*120, the size is 64k!!

This is what I do:

##image = jpg data read from a server with a 352x240 resolution

blob = Blob()
blob.data   = str(image)

data_len="jpg length data: %s" % len(blob.data)
logger.info(data_len) ## size is about 15k
     
## convert blob data into a Image
img = Image(blob)
img.depth = 8
img.magick = "PNG"
s = "!%sx%s" % (160, 120)
img.sample(s)

# convert back into data for streaming purposes
blob = Blob()
img.write(blob)

data_len="png length data: %s" % len(blob.data)
logger.info(data_len)  ## size now 64k?!


what is wrong, or what do I forget to do? Is it the direct conversion from JPG to PNG,
do I need to add a step in between to RGB...
Also, tried to play with quality settings on the image, compressionTypes... nothing seem to help.

Needs advice!

thanks in advance,
Vincent




More information about the Python-list mailing list