GIMP script-fu-newbie here.
I can't see anywhere in the documentation of GIMP 2.6 why this shouldn't work:
;Define the main function
(define (script-fu-rubber-stamp img drawable)
(gimp-image-undo-group-start img)
(plug-in-randomize-pick 1 img drawable 90 7 FALSE 10)
(plug-in-oilify 1 img drawable 5 0)
(gimp-image-undo-group-end img)
)
;Register the script w/ GIMP.
(script-fu-register
"script-fu-rubber-stamp" ;func name
"Rubber Stamp" ;menu label
"Image to rubberstamp" ;description
"Me" ;author
"Copyright 2011, Me" ;copyright notice
"Nov. 2011" ;date created
"" ;image type that the script works on
)
(script-fu-menu-register "script-fu-rubber-stamp" "<Image>/Script-Fu")
It shows up in GIMP, but when I run it, it says:
Error: not enough arguments
But if I look in the Script-FU Console, it seems the be right... unless the error of my ways is not in the functioncalls...
ARGH naturally... script-fu-register needs to say what img and drawable is:
(script-fu-register
"script-fu-rubber-stamp" ;func name
"Rubber Stamp" ;menu label
"Image to rubberstamp" ;description
"Me" ;author
"Copyright 2011, Me" ;copyright notice
"Nov. 2011" ;date created
"" ;image type that the script works on
SF-IMAGE "Input Image" 0
SF-DRAWABLE "Input Drawable" 0
)
Related
im trying to load an image for my game title instead of ASCII, but when i try to load the image, it says that _PUTIMAGE, i&. 0 is an illegal function call.
Does _PUTIMAGE,i& not work for certain file types?
I've tried all the ways the built-in help suggest i load an image, but none of them work.
menu:
CLS
PRINT
i& = _LOADIMAGE("FOrest.jpg")
_PUTIMAGE, i&
PRINT ""
PRINT "What Will Your Heros Name be?:";
Name$ = Ask$(5, 1, CSRLIN, POS(0), 11, 0)
CLS
check_1% = 0 'placeholder for debugingg
COLOR 15, 0
PRINT Name$ + "How Old will Your Hero be?: ";: age% = VAL(Ask$(3, 0, CSRLIN, POS(0), 15, 0))
'INPUT "", age%
i want this image to be loaded
The sourceHandle& and destHandle& cannot be the same or an Illegal Function Call error will occur
Try specifying an explicit destination handle. You want the screen so select 0.
method 1
i& = _LOADIMAGE("forest.jpg")
_PUTIMAGE , i&, 0
method 2
i& = _LOADIMAGE("forest.jpg")
_SOURCE i&
_DEST 0
_PUTIMAGE
It would be best if you verified if loading the image was successful. Check if i& is less than -1.
Did you at least setup a graphics screen for your .jpg picture?
SCREEN 13
i& = _LOADIMAGE("forest.jpg")
_PUTIMAGE , i&, 0
Are you in SCREEN 0 or in a graphics mode?
doing
SCREEN _NEWIMAGE(640, 480, 32)
i = _LOADIMAGE("FOrest.jpg.png") 'this filename was the only one that worked
_PUTIMAGE (0, 0), i
worked but I cant do my other inputs i have at that point where the image loads.
this was in the built in help but previously didnt work. so this is weird, i guess when it works it works
Check if image was loaded correctly:
SCREEN _NEWIMAGE(640, 480, 32)
CLS , _RGB(0, 255, 0)
i& = _LOADIMAGE("FOREST.JPG")
IF i& = -1 THEN PRINT "invalid image": END
_PUTIMAGE (0, 0), i&, 0
END
Can someone tell me why this won't work? I can't for the life of me figure out why it doesn't. It compiles fine, looks fine, and this method has worked everywhere else for me... Really need some help, anyone know what's wrong?
set areatype to (choose from list {"Triagles", "Trapeziums"} with prompt "What would you like to calculate the area of?" with title "Area Calculator")
if areatype contains "Triangles" then
set height to text returned of (display dialog "What is the height of the triangle?" with title "Area Calculator" default answer "")
set base to text returned of (display dialog "What is the base of the triangle?" with title "Area Calculator" default answer "")
set area to (height * base) / 2
display dialog "Area = " & area & " units squared" with title "Area Calculator" buttons {"Cancel", "Go again"}
else
if areatype contains "Trapezium" then
set base1 to text returned of (display dialog "What is one base of the trapezium?" with title "Area Calculator" default answer "")
set base2 to text returned of (display dialog "What is the other base of the trapezium?" with title "Area Calculator" default answer "")
set area to ((a + b) / 2) * h
display dialog "Area = " & area & " units squared" with title "Area Calculator" buttons {"Cancel", "Go again"}
end if
end if
-Thanks
Look at your very first line in the code. You spelled Triangles incorrectly and you needed the "s" in Trapeziums added to the "else" line in the code.
on goAgain()
set areatype to (choose from list {"Triangles", "Trapeziums"} with prompt "What would you like to calculate the area of?" with title "Area Calculator")
if areatype contains "Triangles" then
set height to text returned of (display dialog "What is the height of the triangle?" with title "Area Calculator" default answer "")
set base to text returned of (display dialog "What is the base of the triangle?" with title "Area Calculator" default answer "")
set area to (height * base) / 2
display dialog "Area = " & area & " units squared" with title "Area Calculator" buttons {"Cancel", "Go again"}
if the button returned of the result is "Go again" then
goAgain()
else
return
end if
else
if areatype contains "Trapeziums" then
set base1 to text returned of (display dialog "What is one base of the trapezium?" with title "Area Calculator" default answer "")
set base2 to text returned of (display dialog "What is the other base of the trapezium?" with title "Area Calculator" default answer "")
set height2 to text returned of (display dialog "What is the height of the trapezium?" with title "Area Calculator" default answer "")
set area to ((base1 + base2) / 2) * height2
display dialog "Area = " & area & " units squared" with title "Area Calculator" buttons {"Cancel", "Go again"}
if the button returned of the result is "Go again" then
goAgain()
else
return
end if
end if
end if
end goAgain
goAgain()
I have the following code snippet to add a slide to the end of a Microsoft PowerPoint presentation and designate a title / subtitle:
longSlideCount = ActivePresentation.Slides.Count
With ActivePresentation.Slides
Set slideObject = .Add(longSlideCount + 1, ppLayoutTitle)
End With
' ------------------------------ make the main title ------------------------------------- '
slideObject.Shapes(1).TextFrame.TextRange.Text = "This is the Main Title Text"
slideObject.Shapes(2).TextFrame.TextRange.Text = "This is the SubTitle Text"
Is it possible to shrink / grow the text in the title string to fit on one line in the text frame?
Use .Textframe2.Autosize = msoAutoSizeTextToFitShape
I want to make a script-fu script that takes two images as input. How do I do this? Is there a file selector type?
From the tutorial I know that I can do something like
(script-fu-register
"script-fu-text-box" ;func name
"Text Box" ;menu label
"Creates a simple text box, sized to fit\
around the user's choice of text,\
font, font size, and color." ;description
"Michael Terry" ;author
"copyright 1997, Michael Terry;\
2009, the GIMP Documentation Team" ;copyright notice
"October 27, 1997" ;date created
"" ;image type that the script works on
SF-STRING "Text" "Text Box" ;a string variable
SF-FONT "Font" "Charter" ;a font variable
SF-ADJUSTMENT "Font size" '(50 1 1000 1 10 0 1)
;a spin-button
SF-COLOR "Color" '(0 0 0) ;color variable
SF-ADJUSTMENT "Buffer amount" '(35 0 100 1 10 1 0)
;a slider
)
(script-fu-menu-register "script-fu-text-box" "<Image>/File/Create/Text")
(define (script-fu-text-box inText font fontSize textColor bufferAmount)
And this mentions that if you want it to operate on an open image this should be the first parameter, but what if I want it to operate on two images and join them into one (as layers, but then with some transforms applied)?
Just use the SF-IMAGE parameter type. Once for each image you want as input.
For the script-fu to operate on the active image, the first two parameters should be
SF-IMAGE followed by SF-DRAWABLE, and the script has to be registered to the "" menu.
Add a second SF-IMAGE parameter as third parameter, bellow the SF-IMAGE and chec what you get back.
I have successfully used the following command line to create a new GIF image with some simple text
convert -size 100x100 -font arial label:blah output.gif
I would like to achieve the same result using the COM interface from VBScript, but have not been successful in passing in the same parameters in. Here is my code...
Dim img
Set img = CreateObject("ImageMagickObject.MagickImage.1")
Dim fnm(6)
fnm(0) = "-size"
fnm(1) = "100x100"
fnm(2) = "-font"
fnm(3) = "arial"
fnm(4) = "-label"
fnm(5) = "blah"
fnm(6) = "C:\temp\example.gif"
retval = img.convert(fnm)
wscript.echo("retval " & retval)
I execute this code as follows
cscript example.vbs
and the output I get is this, and no GIF file is created...
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.
Version: ImageMagick 6.7.4-3 2011-12-24 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP
Usage: cscript.exe [options ...] file [ [options ...] file ...] [options ...] file
I'm on Windows7 using ImageMagick-6.7.4-Q16
Does anyone know what I am doing wrong?
[Edit]
In response to Ekkehard's answer I have also tried not using an array. This code will create an output image, but the label is not applied. I also have to pass in a white image as an input as it will not work without one.
msgs = img.convert("C:\temp\blank.gif", "-size", "100x100", "-font", "arial", "label:", "blah", "C:\temp\example.gif")
In the end I gave up trying to get label to work when using the COM+ API and have a solution that uses -draw instead. Ekkehard was right about not using an Array, and instead use individual arguments as shown below.
msgs = img.convert( "c:\temp\blank.gif", "-font", "arial", "-pointsize", "36", "-gravity", "center", "-fill", "blue", "-draw", "text 0,0 'blah'", "c:\temp\example.gif")
In the folder [WhereEver]\ImageMagick-6.7.4-Q16\ImageMagickObject\Tests you'll find two sample scripts (ArrayTest.vbs, SimpleTest.vbs). The most important info from the second:
' The argument list is exactly the same as the utility programs
' as a list of strings. In fact you should just be able to
' copy and past - do simple editing and it will work. See the
' other samples for more elaborate command sequences and the
' documentation for the utility programs for more details.
'
msgs = img.Convert("logo:","-format","%m,%h,%w","info:")
So passing all params in one array is as wrong as attempting to set properties. I used
Dim sSrcFSpec : sSrcFSpec = "..\data\logo.jpg"
Dim sDstFSpec : sDstFSpec = "..\data\logo.png"
If goFS.FileExists(sDstFSpec) Then goFS.DeleteFile sDstFSpec
CreateObject("ImageMagickObject.MagickImage.1").convert "-verbose", sSrcFSpec, sDstFSpec
If Not goFS.FileExists(sDstFSpec) Then WScript.Echo "Failure!"
output:
..\data\logo.jpg JPEG 123x118 123x118+0+0 8-bit DirectClass 16.2KB 0.000u 0:00.006
..\data\logo.jpg=>..\data\logo.png JPEG 123x118 123x118+0+0 8-bit DirectClass 0.030u 0:00.
083
which proves that you'll get results if you pass reasonable arguments. I tried something similar to your test code -
convert -verbose -size 100x100 -font arial -label blah ..\data\example.gif
and got:
convert.exe: missing an image filename `..\data\example.gif' # error/convert.c/ConvertImag
eCommand/3016.
Knowing nothing about ImageMagick, I can only assume that such args assume an existing input file.
So do your COM testing when you have verified the parameters from the command line.
A COM interface is going to expose a series of properties and methods for controlling an object. You wouldn't instantiate it by passing an array of values. In most cases, you would set each property individually. It might look something this (purely an example, I don't know if these are real properties for this object):
Dim img
Set img = CreateObject("ImageMagickObject.MagickImage.1")
img.sizeX = 100
img.sizeY = 100
img.font = "Arial"
img.label = "blah"
retval = img.convert("C:\temp\example.gif")
WScript.echo("retval " & retval)
An object browser or type library viewer can be used to examine the COM object's properties and methods. My favorite is TLViewer.