Re: Script-fu gimp-file-save-thumbnail function | |
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] | |
On Friday 04 January 2008 19:35, Martin Bradley wrote:
> Hi Folks,
>
> >You have an error in your placement of ')'.
>
> That was because I thought set was used similar to (let ..)
>
> >I don't think you need the file save since you haven't changed the
> > file since it was loaded.
>
> I have corrected the arguments. I saved the file first because
> gimp-file-save-thumbnail documentation suggested to do so. I've
> since removed it.
>
> >The SF-VALUE in the register block should be SF-FILENAME.
>
> Yes, had already manage to correct this.
>
> > Where did you come up with 'when'? There is no such function in
> > Script-Fu.
>
> I'd been slowly trying to learn Common Lisp and thought that
> Script-Fu had it. Here is the scheme coding tutorial I was using,
> most likely the wrong thing to be reading.
> http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme-Z-H-1.html#
>node_toc_node_sec_4.1
>
>
>
> (define (script-fu-create-thumb filename)
> (let* ((img 0))
> ;; car needed here because gimp functions return values as
> lists (set! img (car (gimp-file-load 1 filename filename)))
> (gimp-file-save-thumbnail img filename)))
>
> (script-fu-register "script-fu-create-thumb"
> "<Toolbox>/Xtns/Script-Fu/Utils/Thumbnail..."
> "Thumbnail Image"
> "Marty Bradley"
> "Marty Bradley"
> "Dec 2007"
> ""
> SF-FILENAME "Image Name" " ")
May I suugest this code instead of the above? :
from gimpfu import *
def python_fu_create_thumb(filename):
img = pdb.gimp_file_load(filename, filename)
pdb.gimp_file_save_thumbnail(img, filename)
register (
"python-fuc-create-thumb",
"Create Thumbnail of Image File",
"Create Thumbnail of Image File",
"Marty Bradley",
"Marty Bradley",
"jan 2008",
"",
"<Toolbox>/Xtns/Script-Fu/Utils/Thumbnail...",
[(PF_FILENAME, "Image Name". "Filename of the iamge to create
thumbnail", "")],
[],
python_fu_create_thumb
)
main()
So, but for the many parameters to the regiser function, (whuch IMHO
is a missdesign of the python bindings), you have just two lines of
code which are very straight and readable.
No need to match odd parenthesis, no need to worry about lists, and
getting elements inside lists, no need to pre-declare variable in an
obscure "let" statement.
regards,
js
-><-
>
> thank you,
> Martin
>
> _______________________________________________
> Gimp-user mailing list
> Gimp-user@xxxxxxxxxxxxxxxxxxxxxx
> https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user
_______________________________________________
Gimp-user mailing list
Gimp-user@xxxxxxxxxxxxxxxxxxxxxx
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user
[Home] [GIMP Development] [Video For Linux] [Photo] [Yosemite News] [Yosemite Photos] [Yosemite Book Store] [gtk] [KDE] [Scanner] [Gimp's Home] [Gimp Docs] [Gimp on Windows] [Steve's Art] [Webcams] [Share Your Images] [Free Online Dating] [Script Fu]
![]() |
![]() |