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

return image in mod python

Hi i have a problem.

def showimage(req):
from PIL import Image
im=Image.open("c:\image-2.jpg")
im.thumbnail((800,600), Image.ANTIALIAS)
req.sendfile(im)

give me some error.
How can i return this image witdhout save ?
Nov 19 '07 #1
5 1320
Abandoned wrote:
Hi i have a problem.

def showimage(req):
from PIL import Image
im=Image.open("c:\image-2.jpg")
im.thumbnail((800,600), Image.ANTIALIAS)
req.sendfile(im)

give me some error.
Really? I don't see any error. So there can't be one.

Diez
Nov 19 '07 #2
On Nov 19, 12:36 pm, "Diez B. Roggisch" <de...@nospam.web.dewrote:
Abandoned wrote:
Hi i have a problem.
def showimage(req):
from PIL import Image
im=Image.open("c:\image-2.jpg")
im.thumbnail((800,600), Image.ANTIALIAS)
req.sendfile(im)
give me some error.

Really? I don't see any error. So there can't be one.

Diez
It gives me this error:
req.sendfile(im)

TypeError: argument 1 must be string, not instance

Sendfile uses as:
req.sendfile("C:/img.jpg")
But i don't know how can i return when i use PIL before return ?
Nov 19 '07 #3
Abandoned wrote:
On Nov 19, 12:36 pm, "Diez B. Roggisch" <de...@nospam.web.dewrote:
>Abandoned wrote:
Hi i have a problem.
def showimage(req):
from PIL import Image
im=Image.open("c:\image-2.jpg")
im.thumbnail((800,600), Image.ANTIALIAS)
req.sendfile(im)
give me some error.

Really? I don't see any error. So there can't be one.

Diez

It gives me this error:
req.sendfile(im)

TypeError: argument 1 must be string, not instance

Sendfile uses as:
req.sendfile("C:/img.jpg")
But i don't know how can i return when i use PIL before return ?
Then don't use sendfile. I don't know mod_python, but I'm pretty sure you
can output what you want somehow to the output stream. So, do that.

Or go down the easy road, create a temp-file to store the image and send
that.

Diez
Nov 19 '07 #4
On Nov 19, 5:32 pm, "Diez B. Roggisch" <de...@nospam.web.dewrote:
Abandoned wrote:
On Nov 19, 12:36 pm, "Diez B. Roggisch" <de...@nospam.web.dewrote:
Abandoned wrote:
Hi i have a problem.
def showimage(req):
from PIL import Image
im=Image.open("c:\image-2.jpg")
im.thumbnail((800,600), Image.ANTIALIAS)
req.sendfile(im)
give me some error.
Really? I don't see any error. So there can't be one.
Diez
It gives me this error:
req.sendfile(im)
TypeError: argument 1 must be string, not instance
Sendfile uses as:
req.sendfile("C:/img.jpg")
But i don't know how can i return when i use PIL before return ?

Then don't use sendfile. I don't know mod_python, but I'm pretty sure you
can output what you want somehow to the output stream. So, do that.

Or go down the easy road, create a temp-file to store the image and send
that.

Diez- Hide quoted text -

- Show quoted text -
Thank you very much.
Yes if i save this i show with sendfile but i must show this witdhout
save.
Nov 20 '07 #5
Abandoned wrote:
Hi i have a problem.

def showimage(req):
from PIL import Image
im=Image.open("c:\image-2.jpg")
im.thumbnail((800,600), Image.ANTIALIAS)
req.sendfile(im)

give me some error.
How can i return this image witdhout save ?
image = Image.open(...)
image.thumbnail(...)
req.content_type = "image/jpeg"
image.save(req, "jpeg")

Peter
Nov 22 '07 #6

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

Similar topics

5
by: Christoph | last post by:
Hi, I have a script I pass (from Zope) an image file to, to do some PIL image stuff with it. I want a StringIO instance representing the altered image file to be returned. What is the method to...
2
by: Scott Brady Drummonds | last post by:
Can anyone recommend the easiest way of generating thumbnail images using a Python library? I've seen that the Python Image Library (PIL) seems to do this but it isn't installed on my available...
2
by: haddock | last post by:
hi all Is it possible to access the size (with and height) of a .tga image in python? From the documentation I would say no, but I'm pretty new to python... if the answer really is no, has...
17
by: PyPK | last post by:
Hi I am looking for a simple tiff Image reader/writer in python.Can anyone point me to the right one.
1
by: flaerpen | last post by:
Hi, I'm trying to use the function paste() to paste a image into another image but I can't get it work! Is it the right function to use or is there any other function that's better? Here's my very...
3
by: Abandoned | last post by:
Hi.. I want to show the pictures with mod python directly. def showimage(req): some process... open /var/www/a.jpg and print for example if i open: domain.com/a.py/showimage It must show...
0
by: Independent | last post by:
Python programmers may find the application to decoding an encrypted map image format known as Memory Map to produce a standard PNG image file interesting. Someone obviously very well versed in...
0
by: norseman | last post by:
Daniel de Sousa Barros wrote: ================================================ Click Start/settings/control panel/system/advanced/settings(in \ performance area)/advanced/change set System...
1
by: zandrew | last post by:
Hello there everyone. For a summer project I'm doing, I have to use a phone to pass an image I've taken (on the phone) to a dedicated server I've made on a local ubuntu machine. For the upload code,...
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: 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
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?
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
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,...

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.