|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Resize and return image on a website. How?
What I'd like to do is pass the path of an image off to my script, have it resize the image and return the resized image to be used within actual img tags.
Ex: Code:
<img src="resize.py?img=blah.jpg&w=20&h=20"> The only problem I have right now is how to make it actually return an image using PIL. I've seen this done with ASP and COM objects, but as Python is free, it would certainly seem to be a better alternative. Any help or tips are very appreciated, thanks. |
|
#2
|
||||
|
||||
|
I don't know if you've found this yet. But there is an article on devshed on PIL, which might help. What you would need to do is:
1. load the image with PIL 2. resize it 3. and save the image with a slightly different name i.e. masterImage and resizedImage, then use the resizedImage in the webpage rather than it's original. This is of course assuming that the image doesn't need to be dynamically generated, say for each user. In which case, or course, the process would be slightly different. But the basic idea is there .http://www.devshed.com/c/a/Python/Imagine-Python/ Have fun, Mark. Last edited by netytan : October 3rd, 2004 at 11:43 AM. |
|
#3
|
|||
|
|||
|
After 5 hours of searching/testing I managed to get it to work by reading in the file to a StringIO object, resizing the image and storing it into another StringIO object and sending the output straight to the browser.
Thanks for your reply though. My only problem now is a way to map between the physical path and the url path, something equivalent to ASP's Server.MapPath() function. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Resize and return image on a website. How? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|