473,386 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

JPG - PNG conversion problem

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

Jul 18 '05 #1
1 2499
"Raaijmakers, Vincent (GE Infrastructure)" wrote:
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!!


JPEG is a lossy compression format (well, normally - there are some
obscure exceptions to this). It throws away subtle details (details
that the human eye is relatively insensitive to) in order to achieve its
high compression ratios.

PNG uses only lossless compression. You are guaranteed that the image
you get out will be pixel-for-pixel identical to the image you put in.
Unfortunately, this greatly limits the possibilities for compression -
in fact, no lossless compressor can guarantee ANY reduction in file size
over all possible inputs.

Basically, converting a lossy to a lossless format gives you worst of
both worlds - the loss of detail of one, and the large file size of the other.
Jason Harper
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Vladimir Khvostov | last post by:
Hi, We have some DB2 table on the host that has varchar(3200) columns that are used to store binary data (I know that "varchar(3200) for bit data" should have been used, by modifying host table is...
31
by: Bjørn Augestad | last post by:
Below is a program which converts a double to an integer in two different ways, giving me two different values for the int. The basic expression is 1.0 / (1.0 * 365.0) which should be 365, but one...
11
by: Steve Gough | last post by:
Could anyone please help me to understand what is happening here? The commented line produces an error, which is what I expected given that there is no conversion defined from type double to type...
3
by: Steve Richter | last post by:
here is a warning I am getting in a C++ .NET compile: c:\SrNet\jury\JuryTest.cpp(55) : warning C4927: illegal conversion; more than one user-defined conversion has been implicitly applied while...
0
by: VB Programmer | last post by:
Simple ASP.NET 1 site. Opened solution in beta 2 of 2.0. Ran thru conversion wizard and it states: "Conversion Complete. There were some errors during conversion." I view the conversion log...
4
by: Påhl Melin | last post by:
I have some problems using conversion operators in C++/CLI. In my project I have two ref class:es Signal and SignalMask and I have an conversion function in Signal to convert Signal:s to...
14
by: Richard G. Riley | last post by:
Would it be wrong to use "implicit casting" instead of the standards "implicit conversion" when talking about implicit conversions between certain data types. The standard mentions "explicit...
6
by: Dhirendra Singh | last post by:
Hi, The following C++ program is not compiling on my system. #include <iostream> using namespace std; class complex { double re, im; public: complex( ) :re(0), im(0) {}
4
by: Coleen | last post by:
Hi All :-) I'm new to this site. I've been trying to convert several .Net 2003 web applications and getting tons of conversion errors. I found this site to help walk me through the...
8
by: Nikola | last post by:
Hello, I'm writing a String class for C++ and I'm getting the following error message when using operator: test.cpp: In function ‘int main()’: test.cpp:7: error: ISO C++ says that these are...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.