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

how can i return a image in mod python ?

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 me image directly (no redirect or html)

How can i do it ?
I'm sorry for my bad english.
Kind Regards....
Nov 18 '07 #1
3 1954
On Nov 18, 6:46 am, Abandoned <best...@gmail.comwrote:
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 me image directly (no redirect or html)

How can i do it ?
I'm sorry for my bad english.
Kind Regards....
How about:

def showimage(req):
req.content_type="image/jpeg" # Change to you image type
req.sendfile("/path/to/image.jpg")
return apache.OK

HTH

BTW mod_python has its own list :)

--
Arnaud

Nov 18 '07 #2
On Nov 18, 10:27 am, Arnaud Delobelle <arno...@googlemail.comwrote:
On Nov 18, 6:46 am, Abandoned <best...@gmail.comwrote:
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 meimagedirectly (no redirect or html)
How can i do it ?
I'm sorry for my bad english.
Kind Regards....

How about:

def showimage(req):
req.content_type="image/jpeg" # Change to youimagetype
req.sendfile("/path/to/image.jpg")
returnapache.OK

HTH

BTW mod_python has its own list :)

--
Arnaud
Thank you but i have a another 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 #3
On Nov 19, 10:27 am, Abandoned <best...@gmail.comwrote:
[...]
Thank you but i have a another 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 ?
You can use the cStringIO module (http://docs.python.org/lib/module-
cStringIO.html).

HTH

--
Arnaud

Nov 19 '07 #4

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...
5
by: Abandoned | last post by:
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)
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
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...
0
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...

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.