Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 2nd, 2004, 04:32 PM
unclefu unclefu is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 120 unclefu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 57 sec
Reputation Power: 6
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.

Reply With Quote
  #2  
Old October 3rd, 2004, 11:39 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,536 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 11 m 13 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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.
__________________
programming language development: www.netytan.com Hula


Last edited by netytan : October 3rd, 2004 at 11:43 AM.

Reply With Quote
  #3  
Old October 4th, 2004, 11:21 AM
unclefu unclefu is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 120 unclefu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 57 sec
Reputation Power: 6
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Resize and return image on a website. How?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT