Re: [Gimp-user] Script-fu gimp-file-save-thumbnail function
Hi Joao, 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() I don't want to try to get your code working because I know nothing about Python, I know it is a good language. The other reason I'm not happy using it is that it adds another layer of software to a solution that should work on its own. I have still been unable to get the following to work. (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 ) Any other pointers would be gladly accepted. regards, Martin. ___ Gimp-user mailing list Gimp-user@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user
Re: [Gimp-user] Script-fu gimp-file-save-thumbnail function
On Mon, Jan 07, 2008 at 07:30:22PM +, Martin Bradley wrote: I don't want to try to get your code working because I know nothing about Python, I know it is a good language. The other reason I'm not happy using it is that it adds another layer of software to a solution that should work on its own. If you don't want to learn Python that's fine, but please don't spread made up misinformation. PyGIMP and Script-fu both talk to the GIMP PDB directly, there is no extra layer in the Python case. -Yosh ___ Gimp-user mailing list Gimp-user@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user
Re: [Gimp-user] Script-fu gimp-file-save-thumbnail function
Martin Bradley wrote: (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 img filename) (print (gimp-file-save-thumbnail img filename ) [snip] SF-VALUE Image Name You have an error in your placement of ')'. You have one too few at the end of the set! line and one too many at the end of the print line. You have the wrong number of arguments in the call to gimp-file-save. You can see the list of required arguments in the Procedure Browser. I don't think you need the file save since you haven't changed the file since it was loaded. The SF-VALUE in the register block should be SF-FILENAME. Later on I edited the function to be as shown below. [snip] (when (gimp-file-save-thumbnail img) (gimp-message thumbnail saved?) Where did you come up with 'when'? There is no such function in Script-Fu. -- Cheers! Kevin. http://www.ve3syb.ca/ |What are we going to do today, Borg? Owner of Elecraft K2 #2172 |Same thing we always do, Pinkutus: | Try to assimilate the world! #include disclaimer/favourite | -Pinkutus the Borg ___ Gimp-user mailing list Gimp-user@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user
Re: [Gimp-user] Script-fu gimp-file-save-thumbnail function
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 ) thank you, Martin ___ Gimp-user mailing list Gimp-user@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user
Re: [Gimp-user] Script-fu gimp-file-save-thumbnail function
Martin Bradley wrote: 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 Script-Fu scripts are based on the Scheme language. Scheme is a dialect of Lisp. There are a number of Scheme interpreters which may offer slightly different features and compliance with the Scheme standards. The web page you are reading appears to be for the Scheme variant used in mzscheme. Script-Fu as of GIMP 2.4 more closely follows the R5RS. The document you should be reading can be found at http://www.schemers.org/Documents/Standards/R5RS/r5rs.pdf. Some aspects described in the R5RS are not supported in Script-Fu. define-syntax is one of them. -- Cheers! Kevin. http://www.ve3syb.ca/ |What are we going to do today, Borg? Owner of Elecraft K2 #2172 |Same thing we always do, Pinkutus: | Try to assimilate the world! #include disclaimer/favourite | -Pinkutus the Borg ___ Gimp-user mailing list Gimp-user@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user
Re: [Gimp-user] Script-fu gimp-file-save-thumbnail function
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@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user ___ Gimp-user mailing list Gimp-user@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user