--- frosty-logo-source.scm	2008-06-08 17:29:57.875000000 +0300
+++ FrostyLogo2.4_2.6_Final2.scm	2008-07-22 17:52:05.078125000 +0300
@@ -1,11 +1,13 @@
 ;  FROZEN-TEXT effect
 ;  Thanks to Ed Mackey for this one
-;   Written by Spencer Kimball
+;  Written by Spencer Kimball
 
 (define (apply-frosty-logo-effect img
                                   logo-layer
                                   size
-                                  bg-color)
+                                  bg-color
+                                  isnew)	;The parameter isnew is used when the script is called using the logo script (not alpha to logo), in order to make sure some actions are preformed only then
+
   (let* (
         (border (/ size 5))
         (width (+ (car (gimp-drawable-width logo-layer)) border))
@@ -15,22 +17,24 @@
                                             "Sparkle" 100 NORMAL-MODE)))
         (matte-layer (car (gimp-layer-new img width height RGBA-IMAGE
                                           "Matte" 100 NORMAL-MODE)))
-        (shadow-layer (car (gimp-layer-new img width height RGBA-IMAGE
+        (shadow-layer (car (gimp-layer-new img (+ border width) (+ border height) RGBA-IMAGE
                                            "Shadow" 90 MULTIPLY-MODE)))
         (bg-layer (car (gimp-layer-new img width height RGB-IMAGE
                                        "Background" 100 NORMAL-MODE)))
         (selection 0)
+        (stack (car(gimp-image-get-layer-position img logo-layer)))
         )
 
     (gimp-context-push)
 
+    (if ( = isnew 1) (script-fu-util-image-resize-from-layer img shadow-layer))
+
     (gimp-layer-add-mask logo-layer logo-layer-mask)
-    (script-fu-util-image-resize-from-layer img shadow-layer)
-    (gimp-image-add-layer img sparkle-layer 2)
-    (gimp-image-add-layer img matte-layer 3)
-    (gimp-image-add-layer img shadow-layer 4)
+    (gimp-image-add-layer img sparkle-layer (+ 1 stack))
+    (gimp-image-add-layer img matte-layer (+ 2 stack))
+    (gimp-image-add-layer img shadow-layer (+ 3 stack))
+    (gimp-layer-translate shadow-layer (- border) (- border))
     (gimp-image-add-layer img bg-layer 5)
-    (gimp-layer-translate logo-layer border border)
     (gimp-selection-none img)
     (gimp-edit-clear sparkle-layer)
     (gimp-edit-clear matte-layer)
@@ -59,7 +63,6 @@
     (gimp-edit-fill bg-layer BACKGROUND-FILL)
     (gimp-context-set-background '(0 0 0))
     (gimp-edit-fill logo-layer BACKGROUND-FILL)
-;    (gimp-layer-add-mask logo-layer logo-layer-mask)
     (gimp-selection-load selection)
     (gimp-context-set-background '(255 255 255))
     (gimp-edit-fill logo-layer-mask BACKGROUND-FILL)
@@ -75,18 +78,11 @@
     (gimp-selection-none img)
     (gimp-image-remove-channel img selection)
 
-    (for-each (lambda (the-layer)
-              (gimp-layer-resize the-layer (- width border) (- height border)
-                                           (- border) (- border))
-              ; (gimp-layer-translate the-layer border border)
-              )
-              (list sparkle-layer matte-layer bg-layer)
-    )
-
-    (gimp-layer-resize shadow-layer (- width border) (- height border) 0 0)
     (gimp-layer-translate shadow-layer border border)
 
-    (script-fu-util-image-resize-from-layer img logo-layer)
+    (if ( = isnew 1) (script-fu-util-image-resize-from-layer img logo-layer))
+
+    (gimp-layer-translate bg-layer (- 0 border) (- 0 border))
 
     (gimp-context-pop)
   )
@@ -96,12 +92,34 @@
                                      logo-layer
                                      size
                                      bg-color)
-  (begin
+
     (gimp-image-undo-group-start img)
-    (apply-frosty-logo-effect img logo-layer size bg-color)
+
+    ;Checking if the effect size is to big or not
+    (gimp-selection-layer-alpha logo-layer)
+    (gimp-selection-feather img (/ size 5))
+    (gimp-selection-sharpen img)
+
+    (if (= 1 (car(gimp-selection-is-empty img)))
+    (begin
+    (gimp-image-undo-group-end img)
+    (gimp-selection-none img)
+    (gimp-message "Your layer's opaque parts are either to small for this effect size, or they are not inside the canvas. Please fix those bugs and try again.") ))
+
+    (if (= 0 (car(gimp-selection-is-empty img)))
+    (begin
+
+    (gimp-selection-none img)
+    (gimp-layer-resize-to-image-size logo-layer)
+    (apply-frosty-logo-effect img logo-layer size bg-color 0)
+
+    (gimp-selection-none img)
     (gimp-image-undo-group-end img)
     (gimp-displays-flush)
-  )
+
+    )) ;End of if and begin
+  
+
 )
 
 (script-fu-register "script-fu-frosty-logo-alpha"
@@ -129,11 +147,33 @@
         (img (car (gimp-image-new 256 256 RGB)))
         (border (/ size 5))
         (text-layer (car (gimp-text-fontname img -1 0 0 text (* border 2) TRUE size PIXELS font)))
-        )
-    (gimp-image-undo-disable img)
-    (apply-frosty-logo-effect img text-layer size bg-color)
-    (gimp-image-undo-enable img)
-    (gimp-display-new img)
+	(error-string "The text you entered contains only spaces or other charcters which are to small to be used (at least in this font). Please try again with some new text."        )
+    )
+     (if (not (= text-layer -1))		;checking that the text layer was created succesfully - it has more then just empty charcters
+      (begin     ;Checking if the effect size is to big or not
+       (gimp-image-undo-disable img)
+       (gimp-selection-layer-alpha text-layer)
+       (gimp-selection-feather img border)
+       (gimp-selection-sharpen img)
+       
+       (if (= 0 (car(gimp-selection-is-empty img)))	;Checking whether the effect size is to big
+        (begin
+         (apply-frosty-logo-effect img text-layer size bg-color 1)
+         (gimp-selection-all img)
+         (gimp-image-undo-enable img)
+         (gimp-display-new img)
+       ))
+       (if (= 1 (car(gimp-selection-is-empty img)))
+        (begin
+         (gimp-image-delete img)
+         (gimp-message error-string)
+     ))))
+     (if (= text-layer -1)
+      (begin
+       (gimp-image-delete img)
+       (gimp-message error-string)
+     ))
+    
   )
 )
 
@@ -151,4 +191,4 @@
 )
 
 (script-fu-menu-register "script-fu-frosty-logo"
-                         "<Toolbox>/Xtns/Logos")
+                         "<Toolbox>/Xtns/Logos")
\ No newline at end of file
