homeGeek CultureWebstoreeCards!Forums!Joy of Tech!AY2K!webcam

The Geek Culture Forums!


  New Poll  
my profile | directory login | | search | faq | forum home
  next oldest topic   next newest topic
» The Geek Culture Forums!   » The Archives   » The Big Archives   » Python Imaging Library

 - UBBFriend: Email this page to someone!    
Author Topic: Python Imaging Library
Roceal
Geek
Member # 878

Rate Member
Icon 5 posted January 02, 2002 13:49      Profile for Roceal   Author's Homepage     Send New Private Message       Edit/Delete Post 
I'm using python to power an online photo album of sorts for my web site at http://www.jngm.net/pix/

I wrote a little script to make a thumbnail version of an image because I don't want to necessarily shrink down the whole image using smaller width and height attributes on the <IMG> tag in HTML and I definitely don't want to waste HD space for a bunch of thumbnails (even though an individual thumbnail is small, the total number of thumbnails would be pretty high). However, I've noticed that my script is pretty slow, even though all it does is load an image, crop it into a square, shrink it down a bit further, and then print it out. Does anyone have any recommendations/ experience with this type of thing on how I can speed things up a bit? If you want to see some examples of my source code, let me know.

Thanks in advance,
ARJ/Roceal


Posts: 159 | From: That place, you know, with the thing | Registered: Aug 2001  |  IP: Logged
DigitalBill

Solid Nitrozanium SuperFan!
Member # 646

Member Rated:
5
Icon 1 posted January 02, 2002 22:51      Profile for DigitalBill   Author's Homepage     Send New Private Message       Edit/Delete Post 
ARJy,

Not to go off on a tangent here, but would you recommend learning Perl or Python first?

(Also on my list for this year is SQL, possibly some real Java, RealBasic, and mastering the command lines of Linux/OS X...)

bd


Posts: 604 | From: The Wizards of Technology Binary Bunker | Registered: Jan 2001  |  IP: Logged
greycat

Member # 945

Member Rated:
5
Icon 1 posted January 04, 2002 07:49      Profile for greycat   Author's Homepage     Send New Private Message       Edit/Delete Post 
Image processing requires a pretty big handful of CPU cycles. If I were you, I'd pre-generate the thumbnails and serve them as static images.
Posts: 1522 | From: Ohio, USA | Registered: Oct 2001  |  IP: Logged
EngrBohn
Uber Geek
Member # 476

Member Rated:
5
Icon 1 posted January 05, 2002 03:41      Profile for EngrBohn     Send New Private Message       Edit/Delete Post 
- greycat -
If I were you, I'd pre-generate the thumbnails and serve them as static images.

Which coincidentally enough, is just what I'd been working on the last couple days (coding is slow work when you've only got a couple hours each day to do it because of a two-year-old who wants to "help" when he's awake).

http://www.cis.ohio-state.edu/~bohn/code/makethumbnails.csh.txt

Our photo hosting service went under without so much as an "oh by the way", so I hacked this together in C Shell to make thumbnails from Christmas so I can stick them on the server at OSU.

http://www.cis.ohio-state.edu/~bohn/album/december01/

Being a hackjob, it's not the most elegant piece of code, but it suffices except for one detail -- the user's description of the photos cannot contain any blankspaces, quotes, or questionmarks. Probably no dollar signs, either, but I haven't tested that.

Oh, sure, I could download a fully-working piece of code that someone's already prepared:
http://freshmeat.net/search/?site=Freshmeat&q=thumbnail&section=projects
http://www.google.com/search?q=thumbnail+generator
http://sourceforge.net/search/
but where's the fun in that?

------------------
cb
Oooh! What does this button do!?


Posts: 987 | From: United States | Registered: Jul 2000  |  IP: Logged
Roceal
Geek
Member # 878

Rate Member
Icon 1 posted January 07, 2002 15:04      Profile for Roceal   Author's Homepage     Send New Private Message       Edit/Delete Post 
quote:
Originally posted by DigitalBill:
ARJy,
Not to go off on a tangent here, but would you recommend learning Perl or Python first?

Well, I'm not sure I'm the best person to ask on that, as I haven't even really learned any perl, but I certainly like Python 1.5 well enough. I'll be learning 2.2 soon also. I think the nice thing about Python is that you can use it like a scripting language or you can create full-on compiled programs with it as well. The syntax is easy enough to pick up and the docs on the built-in modules are solid. I certainly recommend going through the tutorial that python.org hosts for getting a good introduction to the language.


Posts: 159 | From: That place, you know, with the thing | Registered: Aug 2001  |  IP: Logged
Roceal
Geek
Member # 878

Rate Member
Icon 1 posted January 07, 2002 15:10      Profile for Roceal   Author's Homepage     Send New Private Message       Edit/Delete Post 
quote:
Originally posted by greycat:
Image processing requires a pretty big handful of CPU cycles. If I were you, I'd pre-generate the thumbnails and serve them as static images.

I'll possibly do that when I get my new HD installed (if I can get off my distraction fest and just get it done); but at the moment there really isn't much space to spare on the HD, as I'm using a rather wimpy old PC recycled from work. I have quite a few photos, and I'm generating 2 differently sized sets of thumbnails for each image, so I can forsee that taking up so much space that I won't be able to put anything else on that drive. I was kinda hoping for an interim measure.


Posts: 159 | From: That place, you know, with the thing | Registered: Aug 2001  |  IP: Logged
greycat

Member # 945

Member Rated:
5
Icon 1 posted January 08, 2002 06:35      Profile for greycat   Author's Homepage     Send New Private Message       Edit/Delete Post 
quote:
Originally posted by EngrBohn:
http://www.cis.ohio-state.edu/~bohn/code/makethumbnails.csh.txt

Being a hackjob, it's not the most elegant piece of code, but it suffices except for one detail -- the user's description of the photos cannot contain any blankspaces, quotes, or questionmarks. Probably no dollar signs, either, but I haven't tested that.


Well, you wrote it in csh so you deserve pain.

But if I were feeling generous I'd advise you to plug your security holes by putting "double quotes" around all of your user-input-containing variable dereferences. Too bad I'm not feeling generous.


Posts: 1522 | From: Ohio, USA | Registered: Oct 2001  |  IP: Logged
EngrBohn
Uber Geek
Member # 476

Member Rated:
5
Icon 1 posted January 08, 2002 08:24      Profile for EngrBohn     Send New Private Message       Edit/Delete Post 
- greycat -
Well, you wrote it in csh so you deserve pain.

I agree, using a *real* programming language would've been better. Since I wanted to leverage existing utilities, Perl probably would've been the smartest choice (yes, yes, I know you can use those utilities from other languages: I've done it before myself, but it's a tad cumbersome in most languages). But using Perl would've required a learning curve, which just didn't seem appropriate for what I originally thought would've been a script of less than thirty lines. I started in Bash, which I think would've been a little friendlier to me, until I failed to find an obvious way to iterate over an unspecified number of command-line arguments (I'm quite willing to admit there might be -- and should be! -- a way to do that in Bash, but I didn't find it).

------------------
cb
Oooh! What does this button do!?


Posts: 987 | From: United States | Registered: Jul 2000  |  IP: Logged


All times are Eastern Time  
  New Poll   Close Topic    Move Topic    Delete Topic next oldest topic   next newest topic
 - Printer-friendly view of this topic
Hop To:

Contact Us | Geek Culture Home Page

© 2018 Geek Culture

Powered by Infopop Corporation
UBB.classicTM 6.4.0



homeGeek CultureWebstoreeCards!Forums!Joy of Tech!AY2K!webcam