fx-foundary + glowselection + gimp

;
; The GIMP -- an image manipulation program
; Copyright (C) 1995 Spencer Kimball and Peter Mattis
;
; Selection glow script  for GIMP 2.4
; Copyright (c) 1997 Adrian Likins
; aklikins@eos.ncsu.ed
;
; Tags: glow, selection, effect
;
; Author statement:
;  Makes a "glow" around the outside of the current selection
;
; Format Fixes for http://www.froisa.com/ Jeffrin Jose
; ahiliation@yahoo.co.in
;
;
; --------------------------------------------------------------------
; Distributed by Gimp FX Foundry project
; --------------------------------------------------------------------
;   - Changelog -
;
; Changed on June 15, 2000 by Kevin Cozens 
; Updated for GIMP 1.1.26
;
; Changed on January 29, 2004 by Kevin Cozens 
; Updated for GIMP 2.0pre3
;
; --------------------------------------------------------------------
;
; 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 2 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.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define (my-pair->string pair)
  (cons ((pair? (cdr pair))
     (my-list->string pair))
    (else
     (print "aoeuo")
     (string-append "("   (to-string (car pair))
            " . " (to-string (cdr pair)) ")"))))

(define (flatten-string-list str lst)
  (cond ((not (null? lst))
     (flatten-string-list (string-append str (car lst) " ")
                  (cdr lst)))
    (else
     str)))

(define (my-list->string pair)
  (let ((string-list (flatten-string-list ""
              (map (lambda (x) (to-string x)) pair))))
    (string-append "(" string-list ")")))

(define (to-string arg)
  (cond ((number? arg)
     (number->string arg))
    ((string? arg)
     arg)
    ((symbol? arg)
     "  ")
    ((pair? arg)
     (my-pair->string arg))
    (else
     "  ")))

(define (message-box . args)
  (gimp-message (apply string-append (map to-string args))))


(define (script-fu-glow image
            drawable
            glow-radius
            feather-radius
            glow-color
            glow-opacity
            keep-selection)


    (define seperate-layer TRUE)

    (if (= (car (gimp-selection-is-empty image)) TRUE)
    (begin
; Message box line shortened for line limit for http://www.froisa.com/
      (message-box _"The Script Works only with a selection."))
    (begin
      (define from-selection TRUE)
      (define active-selection (car (gimp-selection-save image)))
;Start an undo group so the process can be undone with one undo
  (gimp-image-undo-group-start image)
;Lets wait with the undo group untill we know if there is a selection.
  (let* (
     (type (car (gimp-drawable-type-with-alpha drawable)))
     (old-gradient (car (gimp-context-get-gradient)))
     (old-fg (car (gimp-context-get-foreground)))
     (old-bg (car (gimp-context-get-background))))

    (gimp-layer-add-alpha drawable)

    (define selection-bounds (gimp-selection-bounds image))
    (define select-offset-x (cadr selection-bounds))
    (define select-offset-y (caddr selection-bounds))
    (define select-width (- (cadr (cddr selection-bounds)) select-offset-x))
    (define select-height (- (caddr (cddr selection-bounds)) select-offset-y))
    (define buffer (+ (* glow-radius 2) (* feather-radius 2) 2))
    (define select-height (+ select-height buffer))
    (define select-width (+ select-width buffer))
    (define select-offset-x (- select-offset-x (/ buffer 2)))
    (define select-offset-y (- select-offset-y (/ buffer 2)))

    (if (= seperate-layer TRUE)
    (begin
      (define effect-layer (car (gimp-layer-new image
                          select-width
                          select-height
                          type
                          _"Glow Layer"
                          100
                          NORMAL-MODE)))
      (gimp-layer-set-offsets effect-layer select-offset-x select-offset-y)
      (gimp-image-add-layer image effect-layer -1)
      (gimp-selection-none image)
      (gimp-edit-clear effect-layer)
      (gimp-selection-load active-selection)
      (gimp-image-set-active-layer image effect-layer ))
    (begin
      (gimp-edit-copy drawable)))
    (define active-layer (car (gimp-image-get-active-layer image)))

    (gimp-selection-grow image glow-radius)
    (gimp-selection-feather image feather-radius)
    (gimp-context-set-background glow-color)
    (gimp-edit-fill active-layer BACKGROUND-FILL)

    (if (= seperate-layer TRUE)
    (begin
      (gimp-selection-load active-selection)
      (gimp-edit-clear active-layer)
      (gimp-layer-set-opacity active-layer glow-opacity))
    (begin
      (gimp-selection-load active-selection)
      (let ((floating-sel (car (gimp-edit-paste active-layer FALSE))))
          (gimp-floating-sel-anchor floating-sel))
      (gimp-selection-load active-selection)))

    (gimp-context-set-gradient old-gradient)
    (gimp-context-set-background old-bg)
    (gimp-context-set-foreground old-fg)

    (if (= keep-selection FALSE)
    (gimp-selection-none image))

    (gimp-image-set-active-layer image drawable)
    (gimp-image-remove-channel image active-selection)

;Finish the undo group for the process
    (gimp-image-undo-group-end image)

    (gimp-displays-flush)))
    ))

(script-fu-register "script-fu-glow"
            _"Glow Selection"
            _"Makes a glow around the outside of the current selection."
            "Adrian Likins "
            "Adrian Likins"
            "10/12/97"
            "RGB RGBA GRAY GRAYA"
            SF-IMAGE "Image" 0
            SF-DRAWABLE "Drawable" 0
            SF-VALUE _"Glow Radius" "2"
            SF-VALUE _"Feather Radius" "10"
            SF-COLOR _"Glow Color" '(255 255 255)
            SF-VALUE _"Glow Opacity (only for seperate layer)" "100"
            SF-TOGGLE _"Keep Selection?" TRUE)

(script-fu-menu-register "script-fu-glow"
                         "/FX-Foundry/Selection Effects")

http://www.flickr.com/photos/ahiliation/5273318947/

Code relating to GIMP – selected color enhancement

/* Color Enhance 0.10 --- image filter plug-in for GIMP
 *
 * Copyright (C) 1999 Martin Weber
 * Copyright (C) 1996 Federico Mena Quintero
 *
 * You can contact me at martweb@gmx.net
 * You can contact the original GIMP authors at gimp@xcf.berkeley.edu
 *
 * 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 2 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.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

static void
enhance_it (const guchar *src, guchar *dest, gdouble vlo, gdouble vhi)
{
  gdouble h, z, v;
  gint    c, m, y;
  gint    k;
  guchar  map[3];

  c = 255 - src[0];
  m = 255 - src[1];
  y = 255 - src[2];

  k = c;
  if (m < k) k = m;
  if (y  255) c = 255;
  m += k;
  if (m > 255) m = 255;
  y += k;
  if (y > 255) y = 255;

  dest[0] = 255 - c;
  dest[1] = 255 - m;
  dest[2] = 255 - y;
}

gimp + selected color enhancement

/* Color Enhance 0.10 --- image filter plug-in for GIMP
 *
 * Copyright (C) 1999 Martin Weber
 * Copyright (C) 1996 Federico Mena Quintero
 *
 * You can contact me at martweb@gmx.net
 * You can contact the original GIMP authors at gimp@xcf.berkeley.edu
 *
 * 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 2 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.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
static void
enhance_it (const guchar *src, guchar *dest, gdouble vlo, gdouble vhi)
{
  gdouble h, z, v;
  gint    c, m, y;
  gint    k;
  guchar  map[3];

  c = 255 - src[0];
  m = 255 - src[1];
  y = 255 - src[2];

  k = c;
  if (m < k) k = m;
  if (y  255) c = 255;
  m += k;
  if (m > 255) m = 255;
  y += k;
  if (y > 255) y = 255;

  dest[0] = 255 - c;
  dest[1] = 255 - m;
  dest[2] = 255 - y;
}

http://www.jeffgraphics.in/2010/12/15/selected-color-enhancement/

Code from GIMP relating to – desaturate based on luminosity

/* GIMP - The GNU Image Manipulation Program
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 *
 * 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 2 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.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
static void
desaturate_region_luminosity (PixelRegion    *srcPR,
                              PixelRegion    *destPR,
                              const gboolean  has_alpha)
{
  const guchar *src  = srcPR->data;
  guchar       *dest = destPR->data;
  gint          h    = srcPR->h;

  while (h--)
    {
      const guchar *s = src;
      guchar       *d = dest;
      gint          j;

      for (j = 0; j w; j++)
        {
          gint luminosity = GIMP_RGB_LUMINANCE (s[RED_PIX],
                                                s[GREEN_PIX],
                                                s[BLUE_PIX]) + 0.5;

          d[RED_PIX]   = luminosity;
          d[GREEN_PIX] = luminosity;
          d[BLUE_PIX]  = luminosity;

          if (has_alpha)
            d[ALPHA_PIX] = s[ALPHA_PIX];

          d += destPR->bytes;
          s += srcPR->bytes;
        }

      src += srcPR->rowstride;
      dest += destPR->rowstride;
    }
}

gimp + desaturate based on luminosity

/* GIMP - The GNU Image Manipulation Program
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 *
 * 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 2 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.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
static void
desaturate_region_luminosity (PixelRegion    *srcPR,
                              PixelRegion    *destPR,
                              const gboolean  has_alpha)
{
  const guchar *src  = srcPR->data;
  guchar       *dest = destPR->data;
  gint          h    = srcPR->h;

  while (h--)
    {
      const guchar *s = src;
      guchar       *d = dest;
      gint          j;

      for (j = 0; j w; j++)
        {
          gint luminosity = GIMP_RGB_LUMINANCE (s[RED_PIX],
                                                s[GREEN_PIX],
                                                s[BLUE_PIX]) + 0.5;

          d[RED_PIX]   = luminosity;
          d[GREEN_PIX] = luminosity;
          d[BLUE_PIX]  = luminosity;

          if (has_alpha)
            d[ALPHA_PIX] = s[ALPHA_PIX];

          d += destPR->bytes;
          s += srcPR->bytes;
        }

      src += srcPR->rowstride;
      dest += destPR->rowstride;
    }
}

http://www.jeffgraphics.in/2010/12/14/204/

Relating inside code which creates a text layer in GIMP

/* GIMP - The GNU Image Manipulation Program
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 *
 * GimpTextLayer
 * Copyright (C) 2002-2004  Sven Neumann
 *
 * 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 2 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.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
/**
 * gimp_text_layer_new:
 * @image: the #GimpImage the layer should belong to
 * @text: a #GimpText object
 *
 * Creates a new text layer.
 *
 * Return value: a new #GimpTextLayer or %NULL in case of a problem
 **/
GimpLayer *
gimp_text_layer_new (GimpImage *image,
                     GimpText  *text)
{
  GimpTextLayer *layer;

  g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
  g_return_val_if_fail (GIMP_IS_TEXT (text), NULL);

  if (! text->text)
    return NULL;

  layer = g_object_new (GIMP_TYPE_TEXT_LAYER, NULL);

  gimp_drawable_configure (GIMP_DRAWABLE (layer),
                           image,
                           0, 0, 1, 1,
                           gimp_image_base_type_with_alpha (image),
                           NULL);

  gimp_text_layer_set_text (layer, text);

  if (! gimp_text_layer_render (layer))
    {
      g_object_unref (layer);
      return NULL;
    }

  return GIMP_LAYER (layer);
}

text layer + gimp + code snippet

/* GIMP - The GNU Image Manipulation Program
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 *
 * GimpTextLayer
 * Copyright (C) 2002-2004  Sven Neumann 
 *
 * 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 2 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.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
/**
 * gimp_text_layer_new:
 * @image: the #GimpImage the layer should belong to
 * @text: a #GimpText object
 *
 * Creates a new text layer.
 *
 * Return value: a new #GimpTextLayer or %NULL in case of a problem
 **/
GimpLayer *
gimp_text_layer_new (GimpImage *image,
                     GimpText  *text)
{
  GimpTextLayer *layer;

  g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
  g_return_val_if_fail (GIMP_IS_TEXT (text), NULL);

  if (! text->text)
    return NULL;

  layer = g_object_new (GIMP_TYPE_TEXT_LAYER, NULL);

  gimp_drawable_configure (GIMP_DRAWABLE (layer),
                           image,
                           0, 0, 1, 1,
                           gimp_image_base_type_with_alpha (image),
                           NULL);

  gimp_text_layer_set_text (layer, text);

  if (! gimp_text_layer_render (layer))
    {
      g_object_unref (layer);
      return NULL;
    }

  return GIMP_LAYER (layer);
}

http://www.jeffgraphics.in/2010/12/11/flower-2/

cd cover + colorize in gimp

Copyright (C) 1995 Spencer Kimball and Peter Mattis . GPL GIMP colorize.c
.
.
.

void
colorize (Colorize    *colorize,
          PixelRegion *srcPR,
          PixelRegion *destPR)
{
  const guchar *src, *s;
  guchar       *dest, *d;
  gboolean      alpha;
  gint          w, h;
  gint          lum;

  /*  Set the transfer arrays  (for speed)  */
  h     = srcPR->h;
  src   = srcPR->data;
  dest  = destPR->data;
  alpha = (srcPR->bytes == 4) ? TRUE : FALSE;

  while (h--)
    {
      w = srcPR->w;
      s = src;
      d = dest;

      while (w--)
        {
          lum = (colorize->lum_red_lookup[s[RED_PIX]] +
                 colorize->lum_green_lookup[s[GREEN_PIX]] +
                 colorize->lum_blue_lookup[s[BLUE_PIX]]); /* luminosity */

          if (colorize->lightness > 0)
            {
              lum = (gdouble) lum * (100.0 - colorize->lightness) / 100.0;

              lum += 255 - (100.0 - colorize->lightness) * 255.0 / 100.0;
            }
          else if (colorize->lightness lightness + 100.0) / 100.0;
            }

          d[RED_PIX]   = colorize->final_red_lookup[lum];
          d[GREEN_PIX] = colorize->final_green_lookup[lum];
          d[BLUE_PIX]  = colorize->final_blue_lookup[lum];

          if (alpha)
            d[ALPHA_PIX] = s[ALPHA_PIX];

          s += srcPR->bytes;
          d += destPR->bytes;
        }

      src  += srcPR->rowstride;
      dest += destPR->rowstride;
    }
}

http://www.jeffgraphics.in/2010/12/09/cd-cover-colorize-in-gimp/

RMS + lomograph

A  Lomograph holds  a charm  all of  its own.  Somehow,  everything is
amplified, making  ordinary objects stand out,  enhancing details that
would normally go  unnoticed. Characterised by ever-changing variables
such as  the mysterious  vignettes that frame  the shot,  light leaks,
lo-fi  grain, beautiful  blurs, the  magical balance  of  contrast and
saturation  just to name  a few.   A combination  these factors  and a
healthy  touch  of  the  unexpected  go  into  making  each  Lomograph
unique. Essentially, Lomography embraces  the element of surprise that
only analogue film photography can bring and wholeheartedly celebrates
the  outcome.   Experiment with  different  kinds  of  films, and  try
different  tips and  techniques, such  as cross-processing  (x-pro) it
works well with Lomographic cameras!

http://www.jeffgraphics.in/2010/12/08/rms-lomograph/