Suppressing the "press any character to close this window" message in Script-Fu

ForumsFor GIMP users ► Suppressing the "press any character to close this window" message in Script-Fu

Sent: 2010-08-01 10:48:31 UTC (over 1 year ago)

From: Dillon

Suppressing the "press any character to close this window" message in Script-Fu

Hi all,

I've written a series of scripts to automate GIMP's script-fu batch
processor. Right now I'm working on starting up multiple asynchronous GIMP
processes.

The problem I'm having right now is with the interactive "press any
character to close this window" message that appears when GIMP finishes
processing a piece of Script-Fu.

I want to suppress that message so that there is no user interaction
required.

Is this possible in Script-Fu?

- Dillon

_______________________________________________
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user

Reply to this message

Sent: 2010-08-01 13:25:42 UTC (over 1 year ago)

From: saulgoode@flashingtwelve.brickfilms.com

Suppressing the "press any character to close this window" message in Script-Fu

Quoting Dillon :

> The problem I'm having right now is with the interactive "press any
> character to close this window" message that appears when GIMP finishes
> processing a piece of Script-Fu.
>
> I want to suppress that message so that there is no user interaction
> required.

I'm not familiar with that message. Could you provide a little more
detail about your process?

> I've written a series of scripts to automate GIMP's script-fu batch
> processor. Right now I'm working on starting up multiple asynchronous GIMP
> processes.

Unless the image processing you are doing is quite involved, you might
find that running a single GIMP instance to be faster if you pass all
of the filenames to it at once. This way you avoid the somewhat
lengthy startup times that GIMP usually experiences.

_______________________________________________
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user

Reply to this message

Sent: 2010-08-01 17:01:07 UTC (over 1 year ago)

From: Kevin Cozens

Suppressing the "press any character to close this window" message in Script-Fu

Dillon wrote:
> I've written a series of scripts to automate GIMP's script-fu batch
> processor. Right now I'm working on starting up multiple asynchronous GIMP
> processes.
>
> The problem I'm having right now is with the interactive "press any
> character to close this window" message that appears when GIMP finishes
> processing a piece of Script-Fu.

I don't believe the message has anything to do with Script-Fu. The message
about "press any character..." sounds like a message from a machine running
the Windows operating system and it wants to close a window that was opened
to run a program and that program has now terminated.

You can get more help if you would provide more information about your
batch processing method and how you are invoking GIMP to run Script-Fu scripts.

_______________________________________________
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user

Reply to this message

Sent: 2010-08-01 21:29:23 UTC (over 1 year ago)

From: Dillon

Suppressing the "press any character to close this window" message in Script-Fu

Sorry guys. I should realize that not everyone is following my plot :)

This is the same script / process you guys helped me with a week or two ago.
I am running GIMP on a Windows machine. I have a directory of XCF files
that I want to export to JPG. I have a batch-save-as-jpg script-fu to do
this. The script-fu is invoked from a PowerShell script. That PowerShell
launches the GIMP batch processor and passes in the script-fu function,
scaling percentage, and a file glob.

##########################################################
#
# START SCRIPT-FU
#
##########################################################
(define (batch-save-as-jpg pattern resize)
(let* (
(filelist (cadr (file-glob pattern 1)))
(fileparts)
(jpgname "")
(filename "")
(image 0)
(newimage 0)
(drawable 0)
(x1 0)
(x2 0)
(y1 0)
(y2 0)
(width 0)
(height 0)
(selection-bounds 0)
)
(gimp-message-set-handler 2)
(gimp-message "Preparing to act on the following files")
(gimp-message pattern)
(while (pair? filelist)
; set filename to the name of the current file in the glob
(set! filename (car filelist))
(gimp-message "The current file is: ")
(gimp-message filename)

; set jpgname by tokenizing on "." and taking everything but the last part
(set! fileparts (strbreakup filename "."))
(set! fileparts (butlast fileparts))
(set! jpgname (string-append (unbreakupstr fileparts ".") ".jpg"))
(gimp-message "The new filename will be: ")
(gimp-message jpgname)
; set image from the file, and then get the first layer and set it to
newimage
(gimp-message "Loading File.")
(set! newimage (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))

; scale the image
(gimp-message "Scaling the Image.")
; From the Resize %, calculate the new coordinates
; Select all so we can calculate the image size
(gimp-selection-all newimage)

(gimp-message "Getting the Image Size")
; Get the image size and store in x1, x2, y1, and y2
(set! selection-bounds (gimp-selection-bounds newimage))
(set! x1 (cadr selection-bounds))
(set! y1 (caddr selection-bounds))
(set! x2 (- (cadr (cddr selection-bounds)) x1))
(set! y2 (- (caddr (cddr selection-bounds)) y1))

; De-select the selection
(gimp-selection-none newimage)

(gimp-message "Calculating the new width and height.")
; Calculate the image width, height
(set! width (- x2 x1))
(set! height (- y2 y1))
(set! width (* width resize))
(set! height (* height resize))
(set! width (/ width 100))
(set! height (/ height 100))
(gimp-message "The new width is: ")
(gimp-message (number->string width))
(gimp-message "The new height is: ")
(gimp-message (number->string height))

; set drawable to the newimage
(gimp-message "Setting the Drawable.")
(set! drawable (car (gimp-image-flatten newimage)))
; Scale the image to the new width and height
(gimp-drawable-transform-scale drawable 0 0 width height 0 2 0 3 0)
; Crop the image down to the new scaled size
(gimp-image-crop newimage width height 0 0)
; Re-display the cropped image
(gimp-displays-flush)

; Remove any existing selections
(gimp-selection-none newimage)
; save the drawable from newimage as jpgname
(gimp-message "Saving the new file.")
(gimp-file-save RUN-NONINTERACTIVE newimage drawable jpgname jpgname)
(set! filelist (cdr filelist))

)
)
)

##########################################################
#
# END SCRIPT-FU
#
##########################################################

##########################################################
#
# START POWERSHELL
#
##########################################################

$Resize = 10
$SourcePath = "c:\test\xcf"
$GimpifiedSourcePath = $SourcePath -replace("\\", "\\")
$Gimp = "gimp-2.6.exe"
$GimpParams = @("-i", "-b",
"`"(batch-save-as-jpg\`"$GimpifiedSourcePath\\*.*\`" $Resize)`"", "-b",
"`"(gimp-quit 0)`"")

$p = [diagnostics.process]::Start($Gimp, $GimpParams)
$p.WaitForExit()

##########################################################
#
# END POWERSHELL
#
##########################################################

The Powershell is waiting for the GIMP process to complete before it
continues the script. This is a problem becomes whenever that GIMP command
finishes, it leaves a hanging command-prompt window open that is waiting for
a key press before it will close. This causes the PowerShell to stop
executing.

This is not standard behavior on Windows. Other commands run this way would
briefly launch a command-prompt, execute, complete, and that command prompt
closes on its own. If it's not part of Script-Fu, perhaps it's part of GIMP
batch mode? If it's not GIMP that's waiting for input, perhaps it's a flag
set when launching the executable that tells Windows if it could close the
command prompt. I don't really know where to look for this.

On Sun, Aug 1, 2010 at 12:00 PM,
wrote:

>
>
> Message: 5
> Date: Sun, 01 Aug 2010 11:01:07 -0400
> From: Kevin Cozens
> Subject: Re: [Gimp-user] Suppressing the "press any character to close
> this window" message in Script-Fu
> To: gimp-user
> Message-ID:
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Dillon wrote:
> > I've written a series of scripts to automate GIMP's script-fu batch
> > processor. Right now I'm working on starting up multiple asynchronous
> GIMP
> > processes.
> >
> > The problem I'm having right now is with the interactive "press any
> > character to close this window" message that appears when GIMP finishes
> > processing a piece of Script-Fu.
>
> I don't believe the message has anything to do with Script-Fu. The message
> about "press any character..." sounds like a message from a machine running
> the Windows operating system and it wants to close a window that was opened
> to run a program and that program has now terminated.
>
> You can get more help if you would provide more information about your
> batch processing method and how you are invoking GIMP to run Script-Fu
> scripts.
>

_______________________________________________
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user

Reply to this message

Sent: 2010-08-02 22:16:20 UTC (over 1 year ago)

From: Sven Neumann

Suppressing the "press any character to close this window" message in Script-Fu

On Sun, 2010-08-01 at 01:48 -0700, Dillon wrote:
> Hi all,
>
>
> I've written a series of scripts to automate GIMP's script-fu batch
> processor. Right now I'm working on starting up multiple asynchronous
> GIMP processes.
>
>
> The problem I'm having right now is with the interactive "press any
> character to close this window" message that appears when GIMP
> finishes processing a piece of Script-Fu.

You get this message because you are running the copy of GIMP that was
compiled as an interactive application with UI. If you don't want any
UI, then don't start the gimp binary, but use the gimp-console binary
instead.

Sven

_______________________________________________
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user

Reply to this message

Sent: 2010-08-06 08:28:51 UTC (over 1 year ago)

From: Dillon

Suppressing the "press any character to close this window" message in Script-Fu

Thank you Sven - that fixed it!

On Tue, Aug 3, 2010 at 12:00 PM,
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 02 Aug 2010 22:17:51 +0200
> From: Sven Neumann
> Subject: Re: [Gimp-user] Suppressing the "press any character to close
> this window" message in Script-Fu
> To: Dillon
> Cc: gimp-user@lists.xcf.berkeley.edu
> Message-ID:
> Content-Type: text/plain; charset="UTF-8"
>
> On Sun, 2010-08-01 at 01:48 -0700, Dillon wrote:
>
> You get this message because you are running the copy of GIMP that was
> compiled as an interactive application with UI. If you don't want any
> UI, then don't start the gimp binary, but use the gimp-console binary
> instead.
>
>
> Sven
>
>
>
>

_______________________________________________
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user

Reply to this message

Welcome!


Lost password?

Not a member? Sign up!

Random tutorials | Latest tutorials

  1. Hot Wallpaper with Flames Hot Wallpaper with Flames 52
  2. Creating an abstract chaos explosion Creating an abstract chaos explosion 10
  3. Create a simple Grunge-Stamp! Create a simple Grunge-Stamp! 7
  4. Ashes to ashes, dust to dust. Dissolve text into particles Ashes to ashes, dust to dust. Dissolve text into particles 3

Latest comments

2.6.12 crashes on startup in windows xp. 2.6.11 works fine. (2 days ago in Last stable 2.6 release: 2.6.12 has arrived)

Thank you! You really helped! The tutorial went great for me! Tha... (5 days ago in [AVATAR] Become a real Na'Vi using GIMP!)

maybe you still selected a channel or so? explicitly click a layer ... (5 days ago in Create cool rifts with translucent lights!)

Poll

Is GIMP an adequate application for you to create printed graphics like flyers, advertisments etc?

Latest forum activities

Your Ad Here

facts & numbers

gimpusers.com RSS feed

48 identi.ca followers
749 Twitter followers

powered by bitfire it services