473,545 Members | 2,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(dat a_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(dat a_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, compressionType s... nothing seem to help.

Needs advice!

thanks in advance,
Vincent

Jul 18 '05 #1
1 2509
"Raaijmaker s, 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
3929
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 not an option at this time). I wrote a Win32 application, which is using DB2 Connect and ODBC to pull the data from the host. I am passing...
31
6582
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 variable becomes 364 and the other one becomes 365. Does anyone have any insight to what the problem is? Thanks in advance. Bjørn
11
7599
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 Test. I expected the same error from the following line, but it compiles fine. The double is silently truncated to an int and then fed in to the...
3
4440
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 calling the constructor 'MyString::MyString(const wchar_t *)' c:\SrNet\jury\JuryTest.h(21) : see declaration of 'MyString::MyString' The class...
0
1183
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 and for the project there is 1 error... http://localhost/Watersmark/ Conversion Issues - http://localhost/Watersmark/: ERROR: Failed to backup...
4
2896
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 SignalMask:s. The reason is I have a free function called WaitSignal that accepts av SignalMask where Signals parameters are supposed to implicitly be...
14
2211
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 conversion" for a cast operation
6
2788
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
2168
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 conversion process: http://webproject.scottgu.com/VisualBasic/Migration2/Migration2.aspx which is great, however, when I follow the steps in this tutorial...
8
5070
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 ambiguous, even though the worst conversion for the first is better than the worst conversion for the second: string.h:19: note: candidate 1: char...
0
7420
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7934
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7446
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6003
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5349
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4966
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3459
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1908
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1033
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.