; Scale Linked Layers rel 0.01
; Created by Graechan
; Comments directed to http://gimpchat.com or http://gimpscripts.com
;
; License: GPLv3
;    This program is free software: you can redistribute it and/or modify
;    it under the terms of the GNU General Public License as published by
;    the Free Software Foundation, either version 3 of the License, or
;    (at your option) any later version.
;
;    This program is distributed in the hope that it will be useful,
;    but WITHOUT ANY WARRANTY; without even the implied warranty of
;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;    GNU General Public License for more details.
;
;    To view a copy of the GNU General Public License
;    visit: http://www.gnu.org/licenses/gpl.html
;
;
; ------------
;| Change Log |
; ------------ 
; Rel 0.01 - Initial Release 
(define (script-fu-scale-linked-layers image drawable
                               new-width 
							   new-height
							   local-origin
							   interpolation)
		
	(gimp-image-undo-group-start image)	

 (let* (    (layerList (vector->list (cadr (gimp-image-get-layers image))))
			(layerId 0))	
	
	(gimp-context-push)
    (gimp-context-set-interpolation interpolation)
	
;;;;begin the script	
	(while (not (null? layerList))
	(set! layerId (car layerList))
	(if (= (car (gimp-drawable-get-linked layerId)) TRUE) (gimp-layer-scale layerId new-width new-height local-origin))
	(set! layerList (cdr layerList)))	

	(gimp-displays-flush)
	(gimp-image-undo-group-end image)
	(gimp-context-pop)
 )
)
(script-fu-register "script-fu-scale-linked-layers"        		    
  "Scale Linked Layers"
  "Will Scale Linked Layers"
  "Graechan"
  "Graechan - http://gimpchat.com"
  "April 2013"
  "RGB* GRAY* INDEXED*"
  SF-IMAGE      "image"      0
  SF-DRAWABLE   "drawable"   0
  SF-ADJUSTMENT "New Width (pixels)" '(250 1 1000 1 10 0 1)
  SF-ADJUSTMENT "New Height(pixels)" '(250 1 1000 1 10 0 1)
  SF-TOGGLE     "Scale From Centre"   FALSE
  SF-ENUM "Scale Mode" '("InterpolationType" "cubic")
)

(script-fu-menu-register "script-fu-scale-linked-layers" "<Image>/Layer")


