Post Reply 

script-fu ok in gimp, not in commad line

Sep 27, 2014, 15:28
Post: #1
script-fu ok in gimp, not in commad line
Hello.

This is my two first script in script-fu
My first script open an image and then call my second to write different text in the image
then save the image with a different name/path.
It works ok in GIMP.

But I have two questions:
1.why do I have to create a white new image in order to be able to call the first script from the Gimp menu ? If I do not create the new image the menu to call my first method is blank.

2.why when I call the first script, it load the image as needed, call the second method but the result is:
nothing is written on the image (second method task)
the image is not kept (end of first script)

The code is:
first (and main) method:
(script-fu-register
"script-fu-crear-firma-ayto" ;func name
"Crear firma ayto" ;menu label
"Crea una firma personalizada segunlos parametros" ;description
"Dominique Perarnaud" ;author
"copyright 2014 Dominique Perarnaud" ;copyright notice
"septiembre 22, 2014" ;date created
"RGB" ;image type that the script works on
;SF-IMAGE "Image" 0
;SF-DRAWABLE "Drawable" 0
SF-STRING "Path imagen de fondo" "c:/Firma/psd/firma_blank.psd" ;a string variable fichero de entrada plantilla de firma
SF-STRING "Path imagen acabada" "c:/Firma/gif/firma_logo_ayto_out1.gif" ;a string variable fichero de entrada plantilla de firma
SF-STRING "Nombre y apellidos" "Dominique PXXXXX" ;a string variable
SF-STRING "Cargo" "Puesto " ;a string variable
SF-STRING "Departamento" "UXXXXXX" ;a string variable
SF-STRING "Texto Ayuntamiento" "DXXXXXXX" ;a string variable
SF-STRING "Telefono y Fax" "Tel +34 XXXX" ;a string variable
;SF-STRING "Text" "MovĂ­l" ;a string variable
)
(script-fu-menu-register "script-fu-crear-firma-ayto" "<Image>/Script-Fu/Crear Firma Ayto" )
;(define (script-fu-crear-firma-ayto image drawable inFilename inFilenameout inNomApel inPuesto inDpto inAyto inTel)
(define (script-fu-crear-firma-ayto inFilename inFilenameout inNomApel inPuesto inDpto inAyto inTel)
(let*
(
; define our local variables
; create a new image:
(theImageWidth 450)
(theImageHeight 89)
;(thePath "c:/Firma/firma_logo_ayto.psd")
;(theImageName "firma")
(theImage) ;abrir la imagen de logo generico del ayuntamiento
(theImage
(car
(gimp-file-load RUN-NONINTERACTIVE inFilename inFilename
)
)
)
(drawable (car (gimp-image-get-active-layer theImage)))
)

;fin de variables

(script-fu-anadir-texto theImage inNomApel 69 5 11 "Verdana Bold") ;nombre apellidos
(script-fu-anadir-texto theImage inPuesto 69 20 11 "Verdana") ;puesto cargo bilingue
(script-fu-anadir-texto theImage inDpto 69 35 11 "Verdana") ;departamento bilingue
(script-fu-anadir-texto theImage inAyto 69 55 11 "Verdana Bold") ;tel fax
(script-fu-anadir-texto theImage inTel 88 73 11 "Verdana") ;tel fax
;(script-fu-anadir-texto theImage inMov 120 75 11 "Verdana") ;movil

;flatten
(gimp-image-flatten theImage)
(set! drawable (car (gimp-image-get-active-layer theImage)))
(file-jpeg-save RUN-NONINTERACTIVE theImage drawable inFilenameout inFilenameout 1 0 0 0 "Firma creada por GIMP programada por Dominique PXXXXX" 0 0 0 0)
;save con nombre diferente
(gimp-display-new theImage)
(gimp-image-clean-all theImage)

;(gimp-quit 0)
)
)

//---------------------
second method
(script-fu-register
"script-fu-anadir-texto" ;func name
"script-fu-anadir-texto" ;menu label
"Anade un texto con variable posX posY tamano fuente" ;description
"Dominique PXXXX" ;author
"copyright 2014 CIM Dominique PXXXX" ;copyright notice
"september 22, 2014" ;date created
"" ;image type that the script works on
SF-IMAGE "Imagen" 0
SF-STRING "Text" "UIZ / CIM" ;Texto marca de agua
SF-VALUE "posX" "55"
SF-VALUE "posY" "5"
SF-VALUE "tamano" "11"
SF-STRING "fuente" "Verdana Bold"
)
(script-fu-menu-register "script-fu-anadir-texto" "<Image>/Script-Fu/Anadir texto")
(define (script-fu-anadir-texto imagen texto posX posY tamano fuente)
(let*
(
(texto-marca (car (gimp-text-fontname imagen -1 posX posY texto 0 FALSE tamano PIXELS fuente)))
)
)
)
Find all posts by this user
Quote this message in a reply
Sep 28, 2014, 03:18
Post: #2
RE: script-fu ok in gimp, not in commad line
(Sep 27, 2014 17:28)ofnuts Wrote:  1) because you script has an image (PF-IMAGE) as a first parameter.... so as long as there is no image in Gimp it cannot be used. Define it as needing no image: "" instead of RGB and remove the Image & drawable parameters.

2) I don't know, but you can try your code interactively in the script-fu console, where you are more likely to see error messages, if any.

PS: this is the 3rd millennium, you are authorized to use Python to write your Gimp scripts instead of a language that was invented half a century ago Smile

Thank you for your help.

1) is working great
2)work with corrections on the " and the \ (winodws syntax)


Thanks a lot.

Ps: I put Python in my todo list
Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Late binding / COM for opening an image into GIMP? i73 2 58 Aug 4, 2017 17:39
Last Post: i73
  Loading PythonFu Plugin: ImportError for .../python/gimp.so (GIMP 2.8.22/OSX/Py2.7.9) joroek 1 119 Jul 11, 2017 07:26
Last Post: ythgilb
  How to close gimp with batch command? flixe 1 133 Jun 19, 2017 12:29
Last Post: ythgilb
  Need help in running a gui script-fu via command line eyalzek 2 223 Oct 4, 2014 14:05
Last Post: eyalzek
  Color menuitems in script or plugin Barbie 4 379 Sep 29, 2014 09:51
Last Post: paynekj

Forum Jump:


GIMP ForumPortalArchiveContactTermsRSS