On Sunday 30 March 2003 12:30, Metnetsky wrote:
> On Sun, 2003-03-30 at 04:27, Thomas Speck wrote:
> > On Sun, 2003-03-30 at 08:40, Metnetsky wrote:
> > > I can't seem to find any good documentation/examples on GDK with
> > > Python.  I'm not trying to do much, just open an image, shrink, 
and save
> > > under a new name.  Simply put, I have a few hundred photos that 
need to
> > > be cut in half by exactly 50%.  The program doesn't need an 
interface,
> > > it should be run from a command prompt with a directory path 
passed as
> > > an argument.  All images in the path are loaded and converted.  
Any
> > > suggestions on where/how to begin this?
> > > 
> > > ~ Matthew
> > 
> > I think what you are looking for is gtk.gdk.Pixbuf. As a starting 
point
> > 
> > import gtk
> > pixbuf = gtk.gdk.pixbuf_new_from_file( 'file' )
> > scaled = pixbuf.scale_simple( pixbuf.get_width()/2,
> >      pixbuf.get_height()/2, gtk.gdk.INTERP_BILINEAR )
> > scaled.save( 'scaled.png', 'png' )
> > 
> > The documenation on this topic isn't the best but maybe you should 
look
> > here:
> > http://www.gnome.org/~james/pygtk-docs/class-gdkpixbuf.html
> > 
> > Thomas
> > 
> Thanks for the tip.
> 
> I tried the above code and some variations on the theme but the Python
> interpreter keeps returning "AttributeError: 'gtk.gdk.Pixbuf' object 
has
> no attribute 'save'".  Any suggestions?  I looked through the
> documentation, but it definitely lacks something to be desired.
> 
> ~ Matthew

Are you trying to resize them or chop them at a certain point. If it's
just a resize, it's probably easier to just use the "convert" program
that is part of ImageMagick rather than reinvent the wheel. I am
almost certain it provides a mechanism to resize files.

HTH,
Dave

_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to