Gimptalk - Premier Gimp Community: Running script from Windows XP command line - Gimptalk - Premier Gimp Community

Jump to content

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

Running script from Windows XP command line

#1 User is offline   Elviswind 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 02-July 06

Posted 02 July 2006 - 09:54 PM

So I've the following script working well thanks to previous posters:

;batch resize

(define
	(script-fu-batch-resize-this
		pattern
		resize)
	(let* ((filelist (cadr (file-glob pattern 1))))
		(while filelist
			(let* ((filename (car filelist))
				(image (car (gimp-file-load 1 filename filename)))
				(drawable (car (gimp-image-get-active-layer image)))
				(width (car (gimp-image-width image)))
				(height (car (gimp-image-height image))))
				(set! width (* width resize))
				(set! height (* height resize))
				(gimp-image-scale image width height)
				(gimp-file-save 1 image drawable filename filename)
				(gimp-image-delete image)
			)
			(set! filelist (cdr filelist))
		)
	)
)

(script-fu-register "script-fu-batch-resize-this"
	"/Script-Fu/Utils/Batch resize this"
	"Resize all files that match the search pattern"
	"Michael Rost"
	"2006, Michael Rost"
	"Rev A - July 02, 2006"
	""
	SF-VALUE "Search String" ""
	SF-VALUE "Resize Constant" "0.5"
)


As I mentioned, this script, since I've registered it with GIMP, runs well from the menu. My issue is that I can't get it to run from the Windows XP command line. I can run GIMP from the command line and even add some switches, such as gimp-2.2 -s to suppress the splash screen. But when I try gimp-2.2 -i -b '(script-fu-batch-resize-this "i:\\pictures\\resize\\*.jpg" .5)' '(gimp-quit 0)' the files aren't resized. When I monitor the task manger, I see gimp-2.2.exe and script-fu.exe load as processes. I also see a second instance of script-fu.exe load, but it terminates after a few seconds. At this point nothing has happened to my files and I have to manually end the gimp-2.2.exe and script-fu.exe processes.

So my question is if the batch processing functionality is not built into the win32 version of GIMP or perhaps I need to access it in a different way. I suppose I can always run scripts from the GIMP menu, but it seems much more elegant and correct to run them from a command line.

My questions + 1 is I've seen RUN-NONINTERACTIVE as an input to a procedure, but my documentation suggests that this input should be an integer which works fine. What's the preferred or correct method?
0

#2 User is offline   saulgoode 

  • Retired Staff
  • PipPipPip
  • Group: Retired Staff
  • Posts: 5,324
  • Joined: 22-August 05

Posted 03 July 2006 - 02:43 AM

I suspect the problem lies with the backslashes in the filename. I am not sure of this as the last time I tried to track down the problem, the person who started the thread chose a different solution.

When calling from the command line, try replacing "i:\\pictures\\resize\\*.jpg" with "i:/pictures/resize/*.jpg".

RUN-NONINTERACTIVE is a predefined constant integer.
Everybody makes their own fun. If you don't make it yourself it's not fun, it's entertainment.
0

#3 User is offline   Elviswind 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 02-July 06

Posted 28 July 2006 - 12:38 PM

Thanks for the suggestion. I've been away from this project for a little while, but I should have some time to play around with it this weekend and have some other features I'd like to add. I read the previous thread that was linked in your post and have noticed a lot of the same behavior.
0

#4 User is offline   gurpuneet 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 02-August 06

Posted 02 August 2006 - 03:29 PM

Even I am having a similar kind of issue.
I am very new to GIMP, so please correct me if I am wrong.
I have installed GIMP2 and tried running the sample from the "http://gimp.org/tutorials/Basic_Batch/"

Tried execute the below line on the command prompt
gimp-2.2.exe --verbose -i -b '(simple-unsharp-mask "test.jpg" 5.0 0.5 0)' '(gimp-quit 0)'

Nothing happens, however a gimp-2.2 process is running but does not give me any output.
Kindly let me know if any other plugin needs to be present for batch command to work.

I have started of with the sample code, but I am looking out for a gimp batch command that would compress all the *.jpg files i.e Indexed image with optimum palette -> number of colours 2 and also flatten the image and finally save the file in the .png format. I have tried these steps thru the GUI but then a command line interface is what I am looking at.

Thanks in advance. This is a very critical requirement for my project and have been struggling all day today. Please help.
:s:
0

#5 User is offline   saulgoode 

  • Retired Staff
  • PipPipPip
  • Group: Retired Staff
  • Posts: 5,324
  • Joined: 22-August 05

Posted 02 August 2006 - 08:32 PM

Make sure that the "test.jpg" file is in the same directory as the GIMP is searching. This will be the directory which first appears if you perform a "File->Open" from the Toolbox after first starting the GIMP.

You should also try to run your script from within the GIMP. Open the Script-fu Console ("Xtns->Script-fu->Script-fu console") and type in your command:

[*] (simple-unsharp-mask "test.jpg" 5.0 0.5 0)

This will often provide a more useful error message and you can sometimes figure out what went wrong by printing out the "errobj":

[*] errobj
Everybody makes their own fun. If you don't make it yourself it's not fun, it's entertainment.
0

#6 User is offline   gurpuneet 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 02-August 06

Posted 03 August 2006 - 12:46 PM

Thanks lot for you help .I was able to run the script thru the Script-fu Console.

However I am still unsuccessful in running it from the command prompt.

On click of file -> open points to d: and i have placed test.jpg in that location.
I have also placed the jpg file in the scripts and the bin folder, it still fails to read it. Not sure which location gimp is referring??
Is there any method to determine which folder it is referring?

Just wanted to check, when I try a simple command "gimp-2.2 --help" , I do not get any output.
The gimp/bin folder is included in the "path". Is my setup rite for the batch processing?

Kindly help...Thank you
0

#7 User is offline   Axon 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 3
  • Joined: 01-December 06

Posted 01 December 2006 - 04:19 AM

Does anyone have a solution for this?

I've been trying for hours to use the command-line under WinXP but even something as simple as the following just hangs:
gimp.exe --help
0

#8 User is offline   Axon 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 3
  • Joined: 01-December 06

Posted 01 December 2006 - 04:53 AM

PROBLEM SOLVED! :h:

I've got my batch script working. But there is no output at the console (--verbose isn't working).

The trouble with the Windows console is just the quotes and slashes. So instead of:
gimp-2.2.exe -d -f -i -b --verbose '(my-gaus "C:\test.bmp" "C:\test_out.bmp")' '(gimp-quit 0)'

use
gimp-2.2.exe -d -f -i -b --verbose "(my-gaus \"C:/test.bmp\" \"C:/test_out.bmp\")" "(gimp-quit 0)"


Thanks to all for this thread. Without it the penny would've taken longer to drop.
0

#9 User is offline   saulgoode 

  • Retired Staff
  • PipPipPip
  • Group: Retired Staff
  • Posts: 5,324
  • Joined: 22-August 05

Posted 01 December 2006 - 06:19 AM

Ahhh, so Windows doesn't use single-quotes (apostrophes) the same way Linux does.

I appreciate you posting your solution. This should permit a lot of people to do command line GIMPing on Windows.
Everybody makes their own fun. If you don't make it yourself it's not fun, it's entertainment.
0

#10 User is offline   cbl016 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 25-June 08

Posted 25 June 2008 - 02:36 PM

To run the second batch script found on http://www.gimp.org/...ls/Basic_Batch/ this command worked for me.

gimp-2.4.exe -i -b "(batch-unsharp-mask \"C:\\gimpbatchtest\\*.bmp\" 25 2.5 0)" -b "(gimp-quit 0)"

Forward slashes only worked when the images were located in the system drive (ie C:/*.bmp) when the images were placed in a directory I had to escape the backslashes.

Hope this helps someone.
0

Share this topic:


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