It is currently Thu Nov 27, 2014 4:06 am


Latest GIMP Scripts & Plug-ins

All times are UTC - 5 hours [ DST ]




Post new topic Reply to topic  [ 26 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: FU-stair-resize.scm
PostPosted: Sun Apr 03, 2011 3:29 pm  (#1) 
Offline
Global Moderator
User avatar

Joined: May 16, 2010
Posts: 11577
Location: "Looking for my eraser" =P
Is there a way to fix the script so the images in each step are kept as separate layers?
So that you are left with a different sized image in each layer?

; FU_stair-resize.scm
; version 2.0 [gimphelp.org]
; last modified/tested by Paul Sherman
; 01/03/2011 on GIMP-2.6.11
;
; ------------------------------------------------------------------
; Original information ---------------------------------------------
;
; Stair re-size is a script for The GIMP
; Resizes the image up or down in multiple steps instead of one.
; The script is located in menu
; "<Image> / Script-Fu / Misc / Stair Interpolation..."
; Last changed: 13 August 2007
; Copyright (C) 2007 Harry Phillips <script-fu@tux.com.au>
;
; 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.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, you can view the GNU General Public
; License version 3 at the web site http://www.gnu.org/licenses/gpl-3.0.html
; Alternatively you can write to the Free Software Foundation, Inc., 675 Mass
; Ave, Cambridge, MA 02139, USA.
;
; End original information ------------------------------------------
;--------------------------------------------------------------------

(define (step-size   stepNumber
         wantedSize
         currentSize)
   
   (let* (
      (stepSize (/ (- wantedSize currentSize) stepNumber))
   )
   
   ;Return stepSize
   stepSize))



(define (FU-stair-resize      theImage
               theLayer
               targetSide
               targetValue
               stepsWanted)

    (let* (
   
       ;Read the image width and height
   (imageWidth (car (gimp-image-width theImage)))
   (imageHeight (car (gimp-image-height theImage)))
   
   (sizeList)
   (targetWidth)
   (targetHeight)
   (realWidth)
   (realHeight)
   (nextWidth)
   (nextHeight)
   (stepsX)
   (stepsY)

    )

    ;Start an undo group so the process can be undone with one undo
    (gimp-image-undo-group-start theImage)

    ;Select none
    (gimp-selection-none theImage)
   
    ;Calculate the required step size
    (if (= targetSide 0)
       ;True width is the target
       (begin
          (set! stepsX (step-size stepsWanted targetValue imageWidth))
          (set! realWidth (+ (* stepsX stepsWanted) imageWidth))
          (set! realHeight (/ (* imageHeight  realWidth) imageWidth))
          (set! stepsY (step-size stepsWanted realHeight imageHeight))
       )
       
       ;False the height is the target
       (begin
          (set! stepsY (step-size stepsWanted targetValue imageHeight))
          (set! realHeight (+ (* stepsY stepsWanted) imageHeight))
          (set! realWidth (/ (* imageWidth  realHeight) imageHeight))
          (set! stepsX (step-size stepsWanted realWidth imageWidth))
       )
    )
   
   ;Set the first resize values
   (set! nextWidth (+ imageWidth stepsX))
   (set! nextHeight (+ imageHeight stepsY))

   ;Change the image size by a step at a time
   (while (> stepsWanted 0)
      (gimp-image-scale theImage nextWidth nextHeight)
      (set! stepsWanted (- stepsWanted 1))
      (set! nextWidth (+ nextWidth stepsX))
      (set! nextHeight (+ nextHeight stepsY))
   )

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

    ;Ensure the updated image is displayed now
    (gimp-displays-flush)
))

(script-fu-register "FU-stair-resize"
   "<Image>/Script-Fu/Step Resize"
   "Resizes the image to desired size using small steps."
   "Harry Phillips"
   "Harry Phillips"
   "13 August 2007"
   "RGB* GRAY*"
   SF-IMAGE      "Image"            0
   SF-DRAWABLE      "Drawable"         0
   SF-OPTION      "Target side"      '("Width" "Height")
   SF-VALUE      "Target value"      "1024"
   SF-ADJUSTMENT   "Numbers of steps"   '(10 2 20 1 1 0 0)
)


Thanks

_________________
Image
____________
OK, . . . . so what's the speed of dark?


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Profile  
 
 Post subject: Re: FU-stair-resize.scm
PostPosted: Sun Apr 03, 2011 5:54 pm  (#2) 
Offline
GimpChat Member

Joined: Apr 12, 2010
Posts: 5877
I was so tempted to reply with a single word:

YES

but i fear you would be no much satisfied :hehe
Anyway for sure is possible modify to preserve the layers and should be even not too hard ...except that may be hard for me...

Wait a lateral thought striked checking now ! :yes it works if you don't mind 1px border (that may be removed by a trivial edit to the script

Open Gmic go to sequence menu/Polaroid

In both "Starting " and "Ending parameters"
Set "Frame Size" and "Bottom size" to 1
"angle" "x-shadow" and "y-shadow all to 0

"Frames" in this case would control the number of the layers

If you don't want the 1px border i suppose the little hack below will solve
Mind that use a similar filter to step resize is a overkill, as use a Nuke to kill a mosquito...anyway as the Nucluar blast will kill the mosquito the script should allow what you asked

But was a 1 minute hack, i didn't test but should work, i slightly change Name and function name of the script to avoid conflict or the script be overwritten by update

################################################

#@gimp PolaroiD : gimp_animate_polaroidd, gimp_animate_polaroidd_preview(1)
#@gimp : Frames = _int(10,2,100)
#@gimp : Output frames = _bool(1)
#@gimp : Output files = _bool(0)
#@gimp : Output folder = _folder()
#@gimp : note = note{"\n<b>Starting parameters :</b>"}
#@gimp : Frame size = int(10,0,400)
#@gimp : Bottom size = int(20,0,400)
#@gimp : X-shadow = float(0,-20,20)
#@gimp : Y-shadow = float(0,-20,20)
#@gimp : Smoothness = float(3,0,5)
#@gimp : Angle = float(0,-180,180)
#@gimp : Zoom = float(1,0.01,1)
#@gimp : note = note{"\n<b>Ending parameters :</b>"}
#@gimp : Frame size = int(10,0,400)
#@gimp : Bottom size = int(20,0,400)
#@gimp : X-shadow = float(0,-20,20)
#@gimp : Y-shadow = float(0,-20,20)
#@gimp : Smoothness = float(3,0,5)
#@gimp : Angle = float(20,-180,180)
#@gimp : Zoom = float(1,0.01,1)
#@gimp : sep = separator(), note = note("<small>Author : <i>David Tschumperl&#233;</i>. Latest update : <i>2010/12/29</i>.</small>")
gimp_animate_polaroidd :
-if $3 filename="$4/gmic_polaroid.png" -else filename="" -endif
-animate gimp_polaroid,"${5-11}",\
"${12-18}",$1,$2,$filename
-r @{-max_whds},0,0,0.5,0.5

gimp_animate_polaroidd_preview :
-gimp_animate_preview gimp_polaroid,"${5-11}",\
"${12-18}",0

################################################

_________________
My 3D Gallery on Deviantart http://photocomix2.deviantart.com/
Main gallery http://www.flickriver.com/photos/photocomix-mandala/
Mandala and simmetry http://www.flickriver.com/photos/photocomix_mandala/

Image

Mrs Wilbress


Last edited by PhotoComix on Sun Apr 03, 2011 6:40 pm, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: FU-stair-resize.scm
PostPosted: Sun Apr 03, 2011 6:36 pm  (#3) 
Offline
GimpChat Member

Joined: Oct 06, 2010
Posts: 2666
I get this error:

Image

_________________
You cannot do a kindness too soon because you never know how soon it will be too late.

~Ralph Waldo Emerson


Top
 Profile  
 
 Post subject: Re: FU-stair-resize.scm
PostPosted: Sun Apr 03, 2011 6:40 pm  (#4) 
Offline
GimpChat Member

Joined: Apr 12, 2010
Posts: 5877
And now ?

i may check in about half a hour , but should work now

_________________
My 3D Gallery on Deviantart http://photocomix2.deviantart.com/
Main gallery http://www.flickriver.com/photos/photocomix-mandala/
Mandala and simmetry http://www.flickriver.com/photos/photocomix_mandala/

Image

Mrs Wilbress


Top
 Profile  
 
 Post subject: Re: FU-stair-resize.scm
PostPosted: Sun Apr 03, 2011 6:50 pm  (#5) 
Offline
Script Coder
User avatar

Joined: Jul 14, 2010
Posts: 628
This does it:
; FU_stair-resize.scm
; version 2.0 [gimphelp.org]
; last modified/tested by Paul Sherman
; 01/03/2011 on GIMP-2.6.11
;
; ------------------------------------------------------------------
; Original information ---------------------------------------------
;
; Stair re-size is a script for The GIMP
; Resizes the image up or down in multiple steps instead of one.
; The script is located in menu
; "<Image> / Script-Fu / Misc / Stair Interpolation..."
; Last changed: 13 August 2007
; Copyright (C) 2007 Harry Phillips <script-fu@tux.com.au>
;
; 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.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, you can view the GNU General Public
; License version 3 at the web site http://www.gnu.org/licenses/gpl-3.0.html
; Alternatively you can write to the Free Software Foundation, Inc., 675 Mass
; Ave, Cambridge, MA 02139, USA.
;
; End original information ------------------------------------------
;--------------------------------------------------------------------

(define (step-size   stepNumber
         wantedSize
         currentSize)
   
   (let* (
      (stepSize (/ (- wantedSize currentSize) stepNumber))
   )
   
   ;Return stepSize
   stepSize))



(define (FU-stair-resize      theImage
               theLayer
               targetSide
               targetValue
               stepsWanted)

    (let* (
   
       ;Read the image width and height
   (imageWidth (car (gimp-image-width theImage)))
   (imageHeight (car (gimp-image-height theImage)))
   
   (sizeList)
   (targetWidth)
   (targetHeight)
   (realWidth)
   (realHeight)
   (nextWidth)
   (nextHeight)
   (stepsX)
   (stepsY)

    )

    ;Start an undo group so the process can be undone with one undo
    (gimp-image-undo-group-start theImage)

    ;Select none
    (gimp-selection-none theImage)
   
    ;Calculate the required step size
    (if (= targetSide 0)
       ;True width is the target
       (begin
          (set! stepsX (step-size stepsWanted targetValue imageWidth))
          (set! realWidth (+ (* stepsX stepsWanted) imageWidth))
          (set! realHeight (/ (* imageHeight  realWidth) imageWidth))
          (set! stepsY (step-size stepsWanted realHeight imageHeight))
       )
       
       ;False the height is the target
       (begin
          (set! stepsY (step-size stepsWanted targetValue imageHeight))
          (set! realHeight (+ (* stepsY stepsWanted) imageHeight))
          (set! realWidth (/ (* imageWidth  realHeight) imageHeight))
          (set! stepsX (step-size stepsWanted realWidth imageWidth))
       )
    )
   
   ;Set the first resize values
   (set! nextWidth (+ imageWidth stepsX))
   (set! nextHeight (+ imageHeight stepsY))

   ;Change the image size by a step at a time
   (while (> stepsWanted 0)
      (set! theLayer (car (gimp-layer-copy theLayer (car (gimp-drawable-has-alpha theLayer)))))
      (gimp-image-add-layer theImage theLayer -1)
      (gimp-layer-scale theLayer nextWidth nextHeight TRUE)
      (set! stepsWanted (- stepsWanted 1))
      (set! nextWidth (+ nextWidth stepsX))
      (set! nextHeight (+ nextHeight stepsY))
   )

    (gimp-image-resize-to-layers theImage)
    ;Finish the undo group for the process
    (gimp-image-undo-group-end theImage)

    ;Ensure the updated image is displayed now
    (gimp-displays-flush)
))

(script-fu-register "FU-stair-resize"
   "<Image>/Script-Fu/Step Resize Keeping Layers"
   "Resizes the image to desired size using small steps."
   "Harry Phillips"
   "Harry Phillips"
   "13 August 2007"
   "RGB* GRAY*"
   SF-IMAGE      "Image"            0
   SF-DRAWABLE      "Drawable"         0
   SF-OPTION      "Target side"      '("Width" "Height")
   SF-VALUE      "Target value"      "1024"
   SF-ADJUSTMENT   "Numbers of steps"   '(10 2 20 1 1 0 0)
)

_________________
Image
Fantasy Cartography and Mapping by RobA


Top
 Profile  
 
 Post subject: Re: FU-stair-resize.scm
PostPosted: Sun Apr 03, 2011 7:32 pm  (#6) 
Offline
GimpChat Member

Joined: Oct 06, 2010
Posts: 2666
It works, PC.

Script works well, too, RobA, thanks! :)

_________________
You cannot do a kindness too soon because you never know how soon it will be too late.

~Ralph Waldo Emerson


Top
 Profile  
 
 Post subject: Re: FU-stair-resize.scm
PostPosted: Sun Apr 03, 2011 8:02 pm  (#7) 
Offline
GimpChat Member

Joined: Apr 12, 2010
Posts: 5877
I overdid when changing function name, one was not to be changed because was the call for the "static" polaroid filter

I believe the RobA script more adapt , at least it doesn't use a Atomic bomb to kill the mosquito, more polaroid doesn't do any real step resize

Did you confront the results?

_________________
My 3D Gallery on Deviantart http://photocomix2.deviantart.com/
Main gallery http://www.flickriver.com/photos/photocomix-mandala/
Mandala and simmetry http://www.flickriver.com/photos/photocomix_mandala/

Image

Mrs Wilbress


Top
 Profile  
 
 Post subject: Re: FU-stair-resize.scm
PostPosted: Sun Apr 03, 2011 8:16 pm  (#8) 
Offline
GimpChat Member
User avatar

Joined: Apr 30, 2010
Posts: 1953
Location: Missouri
This may be a bit off topic but is there a site or tut or reference somewhere that teaches how to make scripts? I used to be pretty good at that in the dawn of civilization and I'd like to tinker with making some for gimp.

_________________
Image
The last time I kept an open mind,
my brain fell out and the dog grabbed it.
Now it's full of dirt, toothmarks, and dog slobber.
No more open minds or dogs for me.


Top
 Profile  
 
 Post subject: Re: FU-stair-resize.scm
PostPosted: Sun Apr 03, 2011 8:19 pm  (#9) 
Offline
GimpChat Member

Joined: Apr 12, 2010
Posts: 5877
Python , Script fu or whatelse ?

_________________
My 3D Gallery on Deviantart http://photocomix2.deviantart.com/
Main gallery http://www.flickriver.com/photos/photocomix-mandala/
Mandala and simmetry http://www.flickriver.com/photos/photocomix_mandala/

Image

Mrs Wilbress


Top
 Profile  
 
 Post subject: Re: FU-stair-resize.scm
PostPosted: Sun Apr 03, 2011 8:42 pm  (#10) 
Offline
GimpChat Member

Joined: Mar 29, 2011
Posts: 347
Location: Wisconsin
One of the sticky topics in this forum has a good list of tutorials, etc.

viewtopic.php?f=9&t=724&start=0

_________________
Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 26 posts ]  Go to page 1, 2, 3  Next

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

* Login  

* Subscribe to Gimp Chat's RSS Feed    * Subscribe to Gimp Chat's Tutorial Feed    * Subscribe to Gimp Chat's G'MIC Feed


Powered by phpBB3 © phpBB Group