Gimptalk - Premier Gimp Community: script-fu batch resize - Gimptalk - Premier Gimp Community

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

script-fu batch resize

#1 User is offline   redforce 

  • Member
  • PipPip
  • Group: Members
  • Posts: 17
  • Joined: 26-August 06

Posted 16 September 2006 - 08:31 PM

I have made a Script-Fu to batch-resize images because I couldn't find one that only resizes images (only thumbnail gallerys etc.)

Just download and put to your scripts directory:

http://www.gimpusers...-resize-2.2.scm (for GIMP 2.2)
http://www.gimpusers...-resize-2.4.scm (for GIMP 2.4)

The script is German but it only has three parameters:
1) path to images, e.g. "/home/richard/tmp/*.jpg"
2) new width
3) new height

You can start the script from Xtns/Script-Fu/Verschiedenes/Mehrere Bilder verkleinern...

More images and detailled infos (text in German) are available at:
http://www.gimpusers...tch-resize.html
0

#2 User is offline   Kiko 

  • Member
  • PipPip
  • Group: Members
  • Posts: 28
  • Joined: 09-September 06

Posted 16 September 2006 - 08:39 PM

cant you just scale the image?
Posted Image
0

#3 User is offline   redforce 

  • Member
  • PipPip
  • Group: Members
  • Posts: 17
  • Joined: 26-August 06

Posted 16 September 2006 - 08:41 PM

I want to scale many images, e.g. the last holiday photos. This is why i need BATCH resize
0

#4 User is offline   PhotoComix 

  • GT Senior Moderator
  • Group: Senior Moderators
  • Posts: 11,288
  • Joined: 13-June 05

Posted 16 September 2006 - 10:58 PM

Quote

the script is German but it only has three parameters:
1) path to images, e.g. "/home/richard/tmp/*.jpg"
2) new width
3) new height


4 parameters i hope: i would like choose a folder for the resized images...or it will overwrite the originals?
0

#5 User is offline   devvv 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 7
  • Joined: 18-August 06

Posted 16 September 2006 - 11:18 PM

it is intended to overwrite the original files.

you can make a copy first and then resize the duplicates.

regards,
0

#6 User is offline   PhotoComix 

  • GT Senior Moderator
  • Group: Senior Moderators
  • Posts: 11,288
  • Joined: 13-June 05

Posted 16 September 2006 - 11:25 PM

Thank
0

#7 User is offline   Narkster 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 27-December 07

Posted 27 December 2007 - 09:55 PM

I tried to use this with no luck and had to deal with it for the holiday's and a silly little electronic photo frame.

The 2.4 script doesn't work out of the box so I am submitting the updaed version for 2.4.

http://www.usaupload.net/d/nmet080o0k0
0

#8 User is offline   hello_earth 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 26-March 08

Posted 26 March 2008 - 07:00 PM

Thank you :) Nice scripts :)
I made my own modification - using single aspect ratio instead of width & height. Some things in code are most possible redundant (e.g. recalculating ratio) so somebody probably can correct this. Anyway :) Hope it's okay to put code in here - no time for safe uploading.

Put all this inside scripts directory (on my computer it's c:\program files\GIMP-2.0\share\gimp\2.0\scripts) in a text file called e.g. batch-scale-ratio.scm) and reload the scripts in GIMP menu->Xtns->Script-fu->Refresh scripts
so then you can see it under GIMP menu->Xtns->Misc

cheers!


(define (script-fu-batch-scale-ratio globexp ratio)
  (define (resize-img n f)
	(let* ((fname (car f))
          (img (car (gimp-file-load 1 fname fname))))
       (let* (
             (drawable   (car (gimp-image-active-drawable img)))
             (cur-width  (car (gimp-image-width img)))
             (cur-height (car (gimp-image-height img)))
			 (new-width  (* ratio cur-width))
			 (new-height (* ratio cur-height))
             (new_ratio      (min (/ new-width cur-width) (/ new-height cur-height)))
             (width      (* new_ratio cur-width))
             (height     (* new_ratio cur-height))
			 )
	  
         (gimp-image-undo-disable img)
         (gimp-image-scale img width height)
         (gimp-file-save 1 img (car (gimp-image-get-active-drawable img)) fname fname)
         (gimp-image-delete img)
	   )
    )
    (if (= n 1) 1 (resize-img (- n 1) (cdr f)))
  )
  (let* ((files (file-glob globexp 0)))
  	(resize-img (car files) (car (cdr files))))
)

(script-fu-register "script-fu-batch-scale-ratio"
		    _"Batch Image Scale By Ratio"
		    "Hey!"
		    "Nicholas Herring and Richard Hirner (http://www.gimptalk.com/forum/topic/Script-fu-Batch-Resi-e-9440-1.html) & ADP (http://www.adp-gmbh.ch/misc/tools/script_fu/ex_10.html), hello_earth"
		    "2008, Nicholas Herring based on a script by Richard Hirner"
		    "March 26, 2008"
		    ""
		    SF-STRING "Full path with wildcards" "C:\\Test\\*.jpg"
		    SF-VALUE "Scaling ratio (min 0.01, max 1)" "0.50")
(script-fu-menu-register "script-fu-batch-scale-ratio"
			 "/Xtns/Misc")


0

#9 User is offline   tatakae 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 23-April 08

Posted 23 April 2008 - 08:47 AM

Quote

Thank you :) Nice scripts :)
I made my own modification - using single aspect ratio instead of width & height. Some things in code are most possible redundant (e.g. recalculating ratio) so somebody probably can correct this. Anyway :) Hope it's okay to put code in here - no time for safe uploading.

Put all this inside scripts directory (on my computer it's c:\program files\GIMP-2.0\share\gimp\2.0\scripts) in a text file called e.g. batch-scale-ratio.scm) and reload the scripts in GIMP menu->Xtns->Script-fu->Refresh scripts
so then you can see it under GIMP menu->Xtns->Misc

cheers!


This is exactly what I have been looking for. Thank you for posting a scaling version!
0

#10 User is offline   fullygimped 

  • Member
  • PipPip
  • Group: Members
  • Posts: 38
  • Joined: 26-July 06
  • LocationMaryland

Posted 13 October 2008 - 07:36 PM

This is awesome - You rock !!
Im MGSfan32! Nice to meet you!
Posted Image
0

#11 User is offline   Tonio 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 23-October 08

Posted 23 October 2008 - 11:30 AM

Ok, so I tried to save that as what you said, into where you said etc. I have looked around, but I am really stupid by the looks of it.

All I wanted was a easy way to convert files from one size to another, pref. in a new folder.. with gimp 2.6... If anyone could help, please do...
0

#12 User is offline   jasshrie 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 20-March 10

Posted 20 March 2010 - 12:15 PM

i was searching for the same thing for Gimp 2.6 and found this:

http://members.ozema...odsond/dbp.html

works perfectly for me!

Good luck!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic