RSS/Atom feed Twitter
Site is read-only, email is disabled

Scaling an image from script?

This discussion is connected to the gimp-user-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

10 of 10 messages available
Toggle history

Please log in to manage your subscriptions.

Scaling an image from script? Leeuw van der, Tim 10 Sep 14:58
  Scaling an image from script? michael chang 10 Sep 16:31
   Scaling an image from script? Michael Schumacher 10 Sep 17:13
    Scaling an image from script? michael chang 10 Sep 19:39
  Scaling an image from script? Roel Schroeven 10 Sep 21:15
  Scaling an image from script? Sven Neumann 11 Sep 01:29
   Scaling an image from script? michael chang 11 Sep 02:00
Scaling an image from script? Leeuw van der, Tim 10 Sep 23:45
  Scaling an image from script? Roel Schroeven 10 Sep 23:50
Scaling an image from script? Leeuw van der, Tim 11 Sep 13:07
Leeuw van der, Tim
2005-09-10 14:58:26 UTC (over 18 years ago)

Scaling an image from script?

Hi,

I have a lot of images that need to be scaled. I wanted to write a (batch) script for that; I found a sample online of how to write batch-scripts. I did find in the function-database some image-scaling functions, but they confuse me unfortunately. What I was hoping for was something that would provide in scripting something very similar to the GUI dialog: change one dimension and the other dimension scales in proportion; and apply interpolation.

Now my confusion is that I do find an image-scale function but that doesn't allow for interpolation; I do find a function that allows for interpolation: drawable-transform-scale. But that function seems to be about transforming a region of an image, not the whole image...

Really, I don't want to become an expert on GIMP scripting! And programming scheme? Sorry, I never got the hang of lisp/scheme :-( so there's an extra obstacle there to the learning of this...

(If I don't get a reasonably workable and simple answer then I think I'll just have to cook up something in Python using PIL and forego the quality interpolation that GIMP has when scaling an image -- I'm quite familiar with Python; but there's no Python for my win-gimp so I'll have to use scheme for GIMP scripting)

regards,

--Tim

michael chang
2005-09-10 16:31:37 UTC (over 18 years ago)

Scaling an image from script?

On 9/10/05, Leeuw van der, Tim wrote:

I have a lot of images that need to be scaled. I wanted to write a (batch) script for that; I found a sample online of how to write batch-scripts.

This will be very confusing, since you're going to have to ensure the script works perfectly on first run (since practically no useful debugging (it's very cryptic) exists for Script-Fu, although what it has is slightly more than e.g. Python-Fu or Perl-Fu). Notably, you have to perform a loop on a glob of the images you're going to modify, and then open each, resize, determine file name (opt), rename(opt, relies on previous), (re)save. Unless someone has a better way. :)

This is very painful. If you didn't understand the above, you may require a much higher knowledge of the inner workings of GIMP in order to do what you want; I'd suggest you use ImageMagick instead. Even I think that this kind of thing is painful - it took me 12 months to figure out how my "wrapper" script on multi-image application was broken because there's no syntax report that tells me exactly what's wrong.

Python for Windows works in GIMP 2.3.3 (devel version, no binaries available), and should be supported in some way, shape, or form in GIMP 2.4.

In the meantime, you may wish to use Python-Fu (it is a powerful language) on Linux, if you can spare the time and space. (However, please don't ask me for help on that case, since I don't know Python.) I understand that it's a major inconvienence, but a dual-boot system provides me with the resources necessary to do my work because Python-Fu and Perl-Fu don't currently work on the latest Windows Stable binary.

I apologize for being unable to give better help, and hope you get to do what you want to do. (But just as a note of future reference, unless you're doing hundreds of images, over and over again with slightly differing settings or identical settings, it's easier to do it by hand than to learn the scripting language, AFAIK. I don't intend to scare you, but that's my personal opinion on the difficulty (and power) of the scripting in GIMP. Not so much unlike Visual Basic, which maybe was easier for some due to a "intelligent" IDE (if you can call it that)).

Michael Schumacher
2005-09-10 17:13:44 UTC (over 18 years ago)

Scaling an image from script?

michael chang wrote:

On 9/10/05, Leeuw van der, Tim wrote:

I have a lot of images that need to be scaled. I wanted to write a (batch) script for that; I found a sample online of how to write batch-scripts.

This will be very confusing, since you're going to have to ensure the script works perfectly on first run (since practically no useful debugging (it's very cryptic) exists for Script-Fu, although what it has is slightly more than e.g. Python-Fu or Perl-Fu).

Not necessarily, you can easily have the script executed interactively and check that it does what you want.

Notably, you have to perform a loop on a glob of the images you're going to modify, and then open each, resize, determine file name (opt), rename(opt, relies on previous), (re)save. Unless someone has a better way. :)

http://www.gimp.org/tutorials/Basic_Batch/ has examples how this is done.

For the basic manipulations, there's also the Batch Processor plug-in, http://members.ozemail.com.au/~hodsond/dbp.html

HTH, Michael

michael chang
2005-09-10 19:39:55 UTC (over 18 years ago)

Scaling an image from script?

On 9/10/05, Michael Schumacher wrote:

michael chang wrote:

This will be very confusing, since you're going to have to ensure the script works perfectly on first run (since practically no useful debugging (it's very cryptic) exists for Script-Fu, although what it has is slightly more than e.g. Python-Fu or Perl-Fu).

Not necessarily, you can easily have the script executed interactively and check that it does what you want.

Apparently I've missed this feature - do you mind telling me where it is?

Roel Schroeven
2005-09-10 21:15:29 UTC (over 18 years ago)

Scaling an image from script?

Leeuw van der, Tim schreef:

(If I don't get a reasonably workable and simple answer then I think I'll just have to cook up something in Python using PIL and forego the quality interpolation that GIMP has when scaling an image -- I'm quite familiar with Python; but there's no Python for my win-gimp so I'll have to use scheme for GIMP scripting)

Is PIL's interpolation not as good as GIMP's, even when using resize with BICUBIC or ANTIALIAS? I wasn't ware of that.

Leeuw van der, Tim
2005-09-10 23:45:34 UTC (over 18 years ago)

Scaling an image from script?

I never actually looked at what PIL could really do for me until tonight, so I wasn't aware before that it could do such interpolations... I'm very pleased that it does; only snatch is that it does lose the EXIF data on the resized image (not sure yet if I mind or not).

I saw the GIMP-Batch examples and it looked rather easy/doable to do this with GIMP batch but then when I looked at the GIMP procudures I got rather confused about which GIMP function to use for the actual resizing...

I'm almost convinced to just use Python, with either ImageMagick or PIL. I wrote 90% of the required Python script already, just need to glue together the final pieces.

Thanks all for hearing me and for advice :-)

cheers,

--Tim

-----Original Message----- From: gimp-user-bounces@lists.xcf.berkeley.edu [mailto:gimp-user-bounces@lists.xcf.berkeley.edu]On Behalf Of Roel Schroeven Sent: Saturday, September 10, 2005 9:15 PM To: gimp-user@lists.xcf.berkeley.edu Subject: [Gimp-user] Re: Scaling an image from script?

Leeuw van der, Tim schreef:

(If I don't get a reasonably workable and simple answer then I think I'll just have to cook up something in Python using PIL and forego the quality interpolation that GIMP has when scaling an image -- I'm quite familiar with Python; but there's no Python for my win-gimp so I'll have to use scheme for GIMP scripting)

Is PIL's interpolation not as good as GIMP's, even when using resize with BICUBIC or ANTIALIAS? I wasn't ware of that.

Roel Schroeven
2005-09-10 23:50:54 UTC (over 18 years ago)

Scaling an image from script?

Leeuw van der, Tim schreef:

I never actually looked at what PIL could really do for me until tonight, so I wasn't aware before that it could do such interpolations... I'm very pleased that it does; only snatch is that it does lose the EXIF data on the resized image (not sure yet if I mind or not).

Ah yes. I've been looking for a Python module to handle EXIF data, but it seemed the only ones I could find could only read it, not write it.

Sven Neumann
2005-09-11 01:29:54 UTC (over 18 years ago)

Scaling an image from script?

Hi,

"Leeuw van der, Tim" writes:

Now my confusion is that I do find an image-scale function but that doesn't allow for interpolation; I do find a function that allows for interpolation: drawable-transform-scale. But that function seems to be about transforming a region of an image, not the whole image...

gimp-drawable-transform-scale[-default] scales the full drawable, not a region of it. I think you misinterpreted the API.

(If I don't get a reasonably workable and simple answer then I think I'll just have to cook up something in Python using PIL and forego the quality interpolation that GIMP has when scaling an image -- I'm quite familiar with Python; but there's no Python for my win-gimp so I'll have to use scheme for GIMP scripting)

The development version of GIMP has Win32 support for gimp-python.

Sven

michael chang
2005-09-11 02:00:45 UTC (over 18 years ago)

Scaling an image from script?

On 9/10/05, Sven Neumann wrote:

Hi,

"Leeuw van der, Tim" writes:

Now my confusion is that I do find an image-scale function but that doesn't allow for interpolation; I do find a function that allows for interpolation: drawable-transform-scale. But that function seems to be about transforming a region of an image, not the whole image...

gimp-drawable-transform-scale[-default] scales the full drawable, not a region of it. I think you misinterpreted the API.

BTW, Drawable refers to a layer, AFAIK. Can't remember if that's the proper translation of the term, but that's what I've been "interpreting" it as, and it works fine for me on single-layered images.

(If I don't get a reasonably workable and simple answer then I think I'll just have to cook up something in Python using PIL and forego the quality interpolation that GIMP has when scaling an image -- I'm quite familiar with Python; but there's no Python for my win-gimp so I'll have to use scheme for GIMP scripting)

The development version of GIMP has Win32 support for gimp-python.

Sven _______________________________________________ Gimp-user mailing list
Gimp-user@lists.xcf.berkeley.edu
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-user

Leeuw van der, Tim
2005-09-11 13:07:23 UTC (over 18 years ago)

Scaling an image from script?

ImageMagick does save it, but I didn't find any win32 binaries for ImageMagick-Python bindings... Also, when resizing the same image with PIL and ImageMagick, the PIL version is smaller but with very similar looking quality...

So my load of images is now being resized by PIL.

This discussion is getting rather off-topic, and I solved my problem (albeit without GIMP), so I think we can close the discussion! :-)

thanks all,

--Tim

-----Original Message----- From: gimp-user-bounces@lists.xcf.berkeley.edu [mailto:gimp-user-bounces@lists.xcf.berkeley.edu]On Behalf Of Roel Schroeven Sent: Saturday, September 10, 2005 11:51 PM To: gimp-user@lists.xcf.berkeley.edu Subject: [Gimp-user] Re: Scaling an image from script?

Leeuw van der, Tim schreef:

I never actually looked at what PIL could really do for me until tonight, so I wasn't aware before that it could do such interpolations... I'm very pleased that it does; only snatch is that it does lose the EXIF data on the resized image (not sure yet if I mind or not).

Ah yes. I've been looking for a Python module to handle EXIF data, but it seemed the only ones I could find could only read it, not write it.