472,988 Members | 2,568 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,988 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 1307
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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.