Post Reply 

Autocrop after fuzzy in a script ?

Jan 30, 2012, 17:19
Post: #1
Autocrop after fuzzy in a script ?
Hello everybody!!

I'm just trying to write a script in order to crop a png file which has a white border.
I tried this but nothing change... :/
Can somebody help me, please ?

Code:
(define (script-crop filename
            )
    (let*
        (
            (image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
            (drawable (car (gimp-image-get-active-layer image)))
        )

        (gimp-fuzzy-select image 1 1 0 CHANNEL-OP-REPLACE TRUE FALSE 0 TRUE)
        
        ; Inverse la sélection
        (gimp-selection-invert image)

        ; crop the image
        (plug-in-autocrop RUN-NONINTERACTIVE image drawable)

        ; clean up the image
        (gimp-file-save RUN-NONINTERACTIVE image drawable filename filename)
        (gimp-image-delete image)
    )
)

Thanks for your help ;-)
Find all posts by this user
Quote this message in a reply
Jan 31, 2012, 07:27
Post: #2
RE: Autocrop after fuzzy in a script ?
Hi,
If I don't use a script, I use the fuzzy select in a pixel at (1;1) which is white(all my border is white), then I invert the selection and I crop it. Then, hopefully, I save my new image!

Example:

My image at start :
   

My image after modification
   

Thanks for your help ofnuts!

NB : It's my first script so I don't really know the syntax of Scheme :/
Find all posts by this user
Quote this message in a reply
Jan 31, 2012, 07:52
Post: #3
RE: Autocrop after fuzzy in a script ?
Thanks ofnuts, I try now your python solution..
Find all posts by this user
Quote this message in a reply
Jan 31, 2012, 08:50
Post: #4
RE: Autocrop after fuzzy in a script ?
After the installation of python(not very easy to find 2.6), I write that :

Code:
#!/usr/bin/env python

# This tells Python to load the Gimp module
from gimpfu import *

# This is the function that will perform actual actions
def autocropLinkedLayers(image,drawable):
    for layer in image.layers:
        if layer.linked:
            print 'Autocropping layer %s' % layer.name
            pdb.gimp_image_set_active_layer(image, layer)
            pdb.plug_in_autocrop_layer(image, layer)

# This is the plugin registration function
register(
    "autocrop",    
    "autocrop",  
    "Ce script reduit l'image au plus utile.",
    "Kim24",
    "Kim24",
    "Janvier 2012",
    "<Image>/MyScripts/autocrop",
    "*",
    [],
    [],
    autocropLinkedLayers,
    )

I reboot Gimp and I found my script but when I run it, nothing happened..
My purpose is to run it in batch mode..(when it will work ^^)
Can you help more please ?
Find all posts by this user
Quote this message in a reply
Jan 31, 2012, 09:16
Post: #5
RE: Autocrop after fuzzy in a script ?
Arf, and now, I don't have anymore my script registred :/
I'm lost!
Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Create new images button & Save as override from Script-fu beniman 12 653 Sep 10, 2014 10:57
Last Post: paynekj
  fuzzy select bounding box pwinward 1 391 Sep 3, 2014 04:35
Last Post: pwinward
  fuzzy select modes katydove 2 404 Mar 26, 2014 11:56
Last Post: katydove
Question Odd Fuzzy Select Tool selection javierdl 4 521 Mar 6, 2014 17:54
Last Post: rich2005
  Line Script 2Old 6 711 Feb 6, 2014 18:50
Last Post: 2Old

Forum Jump:


GIMP ForumPortalArchiveContactTermsRSS