473,385 Members | 1,309 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,385 software developers and data experts.

convert images

hi
i converted some P5 type .pgm images to .jpg using
x=Image.open("oldimage.pgm")
imsz=x.size
newimg=Image.new('L',imsz)
newimg.putdata(x.getdata())
newimg.save("newimg.jpg")

when i again check the pixel data for these images using getdata()
method i,I find that they are slightly different

ie if oldimage.pgm has pixels
[29 31 38 ..., 10 4 18]
then the corresponding jpg image has
[29 31 38 ..., 10 3 17]

why this difference? shouldn't they be identical?can someone pls
explain this?

Jun 27 '08 #1
1 4809
On Sun, 27 Apr 2008 06:42:13 -0700, wilson wrote:

i converted some P5 type .pgm images to .jpg using
[…]
ie if oldimage.pgm has pixels
[29 31 38 ..., 10 4 18]
then the corresponding jpg image has
[29 31 38 ..., 10 3 17]

why this difference? shouldn't they be identical?can someone pls
explain this?
JPEG uses a lossy compression algorithm, i.e. the image loses quality and
therefore the pixel values are not exactly the same as before saving. If
you want get the exact values back you have to use another image format.
For RGB or RGBA data PNG is a good format.

Ciao,
Marc 'BlackJack' Rintsch
Jun 27 '08 #2

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

Similar topics

9
by: gsb | last post by:
I have only used the GD lib a little. Is there a way to convert a file from a .gif to a .jpeg file? Thanks, gsb
2
by: Scott Tilton | last post by:
We have a field that gets filled into a database that our ASP website pulls from. What we would like to be able to do is to take that path and convert it to a virtual path so the website can...
4
by: Dominic | last post by:
Hi guys, In .NET, how can I convert a HTML file to TIFF efficiently? One possible way is that I can first use word automatation to load the HTML up and then print it to TIFF. Is that right?...
1
by: Linda Chen | last post by:
In my application, I need to get download jpeg images from an URL and convert them to gif images and send the gif files to a ftp site. Does .net have any utilities I can use to convert the...
5
by: Carl Gilbert | last post by:
Hi I have some ASP code that I want to run from CD within a VB.NET windows application with a web browser control. However, to get the ASP pages to run without a server is proving quite...
4
by: velu | last post by:
I have created a table MSSQL that contain values and published into Datagrid. The table is typically like this.. Tbl Article Rating Count 1 3 3 2 0 0 3 2 1 4 4 5
1
by: Just D. | last post by:
All, Does anybody know some library to resize/convert images on the fly? I'm especially interested in JPG/GIF/TIF images. Also maybe BMP, but not critical. Are we having some kind of a standard,...
26
by: mark | last post by:
The idea of this is very simle. The site is 800px wide and sits in the middle of the browser window, on either side of the site I want a different background image aligned against it. If I were...
3
by: WPeterson | last post by:
Converting PowerPoint to Flash would absolutely be a good choice to distribute your bulky PowerPoint presentations. You can do the whole PowerPoint to Flash conversion manually or with...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.