79583

How to debug script-fu scripts for gimp in scheme?

<h3>Question</h3>

I try to make some script for gimp, using script-fu, scheme.

Naturally, as a beginner, there are lots of errors and misunderstandings.

Now I'm looking for a way to debug those scripts.

I found (gimp-message), but the result does not show up. I'm not aware if there is a possibility to print debug messages to anywhere I could check them.

Generating new images filled with text would probably work ;-) but looks a bit like an overkill.

What ways to debug a script in gimp are there?


<h3>Answer1:</h3>

The output of gimp-message goes to the "Error console" (if you have this dockable dialog setup), otherwise in a warning dialog.

If you are in Linux or OSX, you can also start Gimp from a terminal and use (print ...) calls, they will show in the terminal.

You can make your life easier and write your scripts in Python (easier to learn, and more powerful...). See here for the doc, here for some examples, and here for some debug tricks for Windows.


<h3>Answer2:</h3>

There may be a better way, but, the way I do it is to:

<ol><li>open the script fu console (Filters -> Script Fu -> Console)</li> <li>edit a file (say for example: /Users/jamesanderson/code/scheme/gimp/learn1.scm</li> <li>type: (load "/Users/jamesanderson/code/scheme/gimp/learn1.scm") into the console</li> <li>hit enter</li> <li>edit file for changes</li> <li>keyboard arrow up (to get get the load function call again without typing)</li> <li>hit enter</li> </ol>

Note this is an extension of my answer based on the comment. When going beyond the simple proof of concept scripts like the above, its important to know that that console retains state between calls. So for instance, if we run this scheme script:

(define jea-test-img-id nil) (define (jea-find-test-img) (car (gimp-image-list)))

and then go to the console and type:

jea-test-img-id

we get as a result:

> jea-test-img-id ()

which is good, the script initiated the variable as needed and we see the result. So var set in script, console retains state change from script. Now lets change the state in the console:

(set! jea-test-img-id (jea-find-test-img))

we call a convenience function that grabs the first image ID in the active image list and store it in the variable we previously declared (which was then nil). Now lets examine the question again:

jea-test-img-id

then the result:

> jea-test-img-id 1

so high level: when you are working on a script, create working variables that hold the things you want to work on, like image, pxiels, widths etc then piece by piece get the functions working. In the end you may collapse it into one clean function once you have the short snippet pieces.

来源:https://stackoverflow.com/questions/53031322/how-to-debug-script-fu-scripts-for-gimp-in-scheme

Recommend

  • Set a unique tag to each instance of Terraform aws_autoscaling_group module
  • Custom SOAP 1.1 header and mustUnderstand attribute
  • Don't Understand Bundler Interaction with Gems
  • Android - Javascript: how to execute jquery in webview
  • Binary Tree Bin Packing Algorithm in C
  • SKLabelNode removes leading and trailing spaces - How can I stop that?
  • Linq: Find Element in a Collection
  • C# Extract public key from RSA PEM private key
  • How do you send emails from Angular controllers on the Mean.js stack?
  • A JNI error has occurred, while executing .jar file from command prompt
  • SAS change date format
  • Unable to select a space or join an organization on run.pivotal.io
  • Extract Data from a Web Page - using VBA
  • Reading large text file very slow
  • Existing data serialized as hash produces error when upgrading to Rails 5
  • JSF validateLength question
  • Coin change recursive approach
  • Parsing string using the Scanner class
  • Running iPhone crash Logs from testers on XCode
  • if you have a DLL creating a bitmap in memory, how to return it to the browser?
  • Unable to connect to AWS RDS through PDO
  • Is possible having two COM STA instances of the same component?
  • Admob in ListView not clickable
  • Checking for valid enum types from protobufs
  • JavaMail connection problems [duplicate]
  • Add checkbox dynamically using angular 2
  • How to make Rss News Reader application in android …? [closed]
  • Getting the type of a “Type” in C# reflection
  • C++ STL stack pop operation giving segmentation fault
  • Drag and drop unicode TText in DelphiXe4
  • Using redis as an LRU cache for postgres
  • `$http:badreq Bad Request Configuration` - from angular post method, what is wrong here?
  • Comma decimal separator is ignored by ASP.NET MVC model binder
  • Apple Mach-O Linker error (“duplicate symbol”)
  • media foundation H264 decoder not working properly
  • Access to a Matlab gui from the web
  • ARKit code issue {unknown error -1=ffffffffffffffff error: Task failed with exit 1}