473,386 Members | 1,795 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.

How to write and save image from data?

8
in simple word i want to have an image saved by the program to hard disc that the size is 100x100 pixels the left upper pixel is black and the right lower pixel is white. this is not my problem but as an example will help me to know how use commands to wright an image from data.
thank you for your help.
Feb 3 '11 #1
3 14179
bvdet
2,851 Expert Mod 2GB
This is not exactly what you want, but writes an image to disc that varies from black to white, left to right.
Expand|Select|Wrap|Line Numbers
  1. from PIL import Image
  2.  
  3. im = Image.new("RGB", (255,100))
  4. for x in range(im.size[0]):
  5.     for y in range(im.size[1]):
  6.         im.putpixel((x,y), (x,x,x))
  7.  
  8. im.save("pix.png")
Feb 3 '11 #2
sbtunx
8
thank you bvdet that is helpful for me. also i have question about putpixel command it seams to be slow . how can we use other commands for better response? completing the above code.
Feb 3 '11 #3
bvdet
2,851 Expert Mod 2GB
Would im.putdata() work better for you?
Expand|Select|Wrap|Line Numbers
  1. from PIL import Image
  2.  
  3. im = Image.new("RGB", (255,100))
  4. data = [(x,x,x) for y in range(im.size[1]) for x in range(im.size[0])]
  5. im.putdata(data)
  6. im.save("pix.png") 
Feb 4 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Edwin Young | last post by:
Hi, I'm writing a fractal-generating program in a mixture of C and Python. Python handles all the GUI parts using PyGTK. After finishing the calculations, I have a buffer containing the RGB data...
2
by: Tiro Orsa | last post by:
Hey all... GOAL: My end goal is to send a web page (single file) as an attachment (not embedded) via email to any of the main email clients (Eudora, Outlook, etc). Users see a single web page...
5
by: Jack Fox | last post by:
I'm still new to Xml, but finding it very useful. Conceptually what I want to do is compress an XmlDocument, save it to SQL Server as image data, read it back and restore it to an XmlDocument. ...
4
by: Andy | last post by:
Hello All: I have a field in the database that is an Image. I have no idea how the data is stored in here (Image, compressed, encrypted, plain text, etc). I am trying to write the contents to...
0
by: mattmerc | last post by:
Hi all, I have an web application where security staff can enter incidents. Part of the form allows the user to describe person(s) involved in an incident. My company just so happens to have a...
6
by: Neo Geshel | last post by:
About 4 months ago I came across this one web page that talked about streaming raw image data (from a database, for example) directly to a web page without requiring a secondary ASPX page to...
2
by: Ed | last post by:
Hope someone can help me out... I have been tasked to read some image data from an sql database and save the files to flat files. OK, sounds easy as I'v used BLOBs before. But this is an old...
4
by: psnanu | last post by:
Hi, I have an image file and I have to store the image data into an existing file in binary. How do I do this in VB? thanks.
6
by: Jerry Spence1 | last post by:
I am using a network camera that saves the image in a byte array in memory (via their ocx component, and in the OnNewImage event I can get the pointer to the image and the byte length as...
2
by: aznimah | last post by:
Hi, i need help on how to save the image that return from picturebox? basically the program works, 1)Read image (.png)--> load into pictureBox1 2)Fire button save to save the image from...
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: 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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
0
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...

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.