You are here

Outline Crop/Cutout Capability for Image

Can anybody advise if there is the capability in GIMP to trace the outline of an image and crop it accordingly - I am trying to get rid of the white box that normally surrounds an image after cropping it.

Thanks in advance for any help.

John

Forums: 

you can't have box around after cropping the image, is absolutely not normal

That may happen only if you crop only the layer ,not the image

Simple solution is use Image/crop to selection

If you are trying to remove the background, this script:
http://www.silent9.com/incoming/scripts/transbg.scm
may help.

-Rob A.

Select white area with magic wand. Grow selection by 2px or so. Invert selection, press delete on keyboard.

Then you should be able to autocrop the image just fine :D

GIMP 2.6
Win Vista

I copied transbg.scm to c:\Users\username\.gimp-2.6\scripts\transbg.scm

However, I'm not seeing it in Script-Fu (refreshed/restarted)

How is this script enabled and called up?

Thanks :-)

In windows/search you may have a dumb default:
"hide extension for commune file"

If that is checked extensions as jpg and HERE THE POINT as .txt
will be hidden

So you will never notice VISTA adding a txt extension to your .scm file...as you may have not notice that when saving anything similar to a text, as a code, you have not 1 but 2 option

first and very visible is save as .txt, the second, a bit more hidden,(do you know dropdown list? ..you click and more option pop out ) is save as "ALL FILES " and is that correct.

For Microsoft save as "all files" means "save as it is do not change file extension "...

So change that dumb default and download again, this time saving as "all files"

I'll check into this, thanks :-)

How is this used? (of course, once I get it enabled)

In other words, when I have an image in the editor, where can I find this tool in the editor?

Thanks

The script will show up under Layers->Transparency.

-Rob A>

Super thanks!!!!

I am using Transbg.scm in script-Fu and it is working perfectly. I need exact script to run for many files and therefore I made a batch program from it. The batch runs on Windows Vista normally, but none of the images are being changed. I don't know what I am doing wrong. I need your advice. Would you please give me suggestion how can I fix it.

This is the script:
(define (script-fu-batch-trans-bg pattern inThresh inSize inHoles)

(let* ((filelist (cadr (file-glob pattern 1))))

(while (not (null? filelist))
(let* (
(filename (car filelist))
(image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
(drawable (car (gimp-image-get-active-layer image)))
)
(BGColour (car (gimp-image-pick-color image drawable 0 0 FALSE FALSE 0)))

(gimp-context-push)
(gimp-image-undo-group-start image)
; add alpha to layer if not exists
(if (equal? (car (gimp-drawable-has-alpha drawable)) FALSE)
(gimp-layer-add-alpha drawable))

(let *
(
(dupLayer (car (gimp-layer-copy drawable TRUE)))
(origSel (car (gimp-selection-save image)))
)

(gimp-selection-none image)
(gimp-image-add-layer image dupLayer -1)

; colour to alpha on dupLayer
(plug-in-colortoalpha RUN-NONINTERACTIVE image dupLayer BGColour)

(if (equal? inHoles TRUE)
(gimp-by-color-select drawable BGColour inThresh CHANNEL-OP-REPLACE TRUE FALSE 0 FALSE)
(gimp-fuzzy-select drawable 0 0 inThresh CHANNEL-OP-REPLACE FALSE 0 FALSE)
)

; grow selection by inSize
(gimp-selection-grow image inSize)
(gimp-edit-clear drawable)

;invert selection
(gimp-selection-invert image)

;fill
(gimp-context-set-foreground BGColour)
(gimp-edit-fill drawable FOREGROUND-FILL)

;merge down dupLayer to drawable... might have to play with layer names
(gimp-image-set-active-layer image (car (gimp-image-merge-down image dupLayer CLIP-TO-IMAGE)))

(gimp-selection-load origSel)
(gimp-image-remove-channel image origSel)
)

(gimp-image-undo-group-end image)
(gimp-context-pop)
(gimp-displays-flush)

;Done

(gimp-file-save RUN-NONINTERACTIVE
image drawable filename filename)
(gimp-image-delete image))

(set! filelist (cdr filelist))

;while
)

;let
)
)

Run it on command line:
Gimp-2.6 --verbose -i -b "(script-fu-batch-trans-bg \"D:/test/*.png\" 25 1 TRUE)" -b "(gimp-quit 0)"

The console message:
Starting extension: 'extension-script-fu'
No batch interpreter specified, using the default 'plug-in-script-fu-eval'.
batch command executed successfully
EXIT: gimp_exit
EXIT: gimp_real_exit
Writing 'C:\Users\farah\.gimp-2.6\templaterc'
Writing 'C:\Users\farah\.gimp-2.6\parasiterc'
Writing 'C:\Users\farah\.gimp-2.6\unitrc'
EXIT: batch_exit_after_callback

Thank you in advance for your help

I am using Transbg.scm in script-Fu and it is working perfectly. I need exact script to run for many files and therefore I made a batch program from it. The batch runs on Windows Vista normally, but none of the images are being changed. I don't know what I am doing wrong. I need your advice. Would you please give me suggestion and comments.

This is the script:
(define (script-fu-batch-trans-bg pattern inThresh inSize inHoles)

(let* ((filelist (cadr (file-glob pattern 1))))

(while (not (null? filelist))
(let* (
(filename (car filelist))
(image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
(drawable (car (gimp-image-get-active-layer image)))
)
(BGColour (car (gimp-image-pick-color image drawable 0 0 FALSE FALSE 0)))

(gimp-context-push)
(gimp-image-undo-group-start image)
; add alpha to layer if not exists
(if (equal? (car (gimp-drawable-has-alpha drawable)) FALSE)
(gimp-layer-add-alpha drawable))

(let *
(
(dupLayer (car (gimp-layer-copy drawable TRUE)))
(origSel (car (gimp-selection-save image)))
)

(gimp-selection-none image)
(gimp-image-add-layer image dupLayer -1)

; colour to alpha on dupLayer
(plug-in-colortoalpha RUN-NONINTERACTIVE image dupLayer BGColour)

(if (equal? inHoles TRUE)
(gimp-by-color-select drawable BGColour inThresh CHANNEL-OP-REPLACE TRUE FALSE 0 FALSE)
(gimp-fuzzy-select drawable 0 0 inThresh CHANNEL-OP-REPLACE FALSE 0 FALSE)
)

; grow selection by inSize
(gimp-selection-grow image inSize)
(gimp-edit-clear drawable)

;invert selection
(gimp-selection-invert image)

;fill
(gimp-context-set-foreground BGColour)
(gimp-edit-fill drawable FOREGROUND-FILL)

;merge down dupLayer to drawable... might have to play with layer names
(gimp-image-set-active-layer image (car (gimp-image-merge-down image dupLayer CLIP-TO-IMAGE)))

(gimp-selection-load origSel)
(gimp-image-remove-channel image origSel)
)

(gimp-image-undo-group-end image)
(gimp-context-pop)
(gimp-displays-flush)

;Done

(gimp-file-save RUN-NONINTERACTIVE
image drawable filename filename)
(gimp-image-delete image))

(set! filelist (cdr filelist))

;while
)

;let
)
)

Run it on command line:
Gimp-2.6 --verbose -i -b "(script-fu-batch-trans-bg \"D:/test/*.png\" 25 1 TRUE)" -b "(gimp-quit 0)"

The console message:
Starting extension: 'extension-script-fu'
No batch interpreter specified, using the default 'plug-in-script-fu-eval'.
batch command executed successfully
EXIT: gimp_exit
EXIT: gimp_real_exit
Writing 'C:\Users\farah\.gimp-2.6\templaterc'
Writing 'C:\Users\farah\.gimp-2.6\parasiterc'
Writing 'C:\Users\farah\.gimp-2.6\unitrc'
EXIT: batch_exit_after_callback

Thank you in advance for your help

forget first reply, "crop" confused me i call that "cut"

if you have no transparency but white is because your imagine has no alpha (= transparency ) channel

you may add it from Layer/transparency/add alpha channel

you may try if the ffat script speed up, but know about of the transparency channel (alpha channel) is important

No alpha= no transparency= added solid color (that active for BG )

Subscribe to Comments for "Outline Crop/Cutout Capability for Image"