It is currently Thu Dec 08, 2016 3:08 pm


Latest GIMP Scripts & Plug-ins

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 26 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject: Re: FU-stair-resize.scm
PostPosted: Sun Apr 03, 2011 8:49 pm  (#11) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 13488
Location: "Looking for my eraser" =P
RobA wrote:
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)
)


Excellent Rob! Exactly what i needed.

Image

PC i couldn't get that to work for me i got 10 layers of all the same size images...sorry.
it works i am sure i just am not doing it correctly.

_________________
Image


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

Joined: Apr 12, 2010
Posts: 5872
i did not tested yet maybe i should have applied the same change also to the "static" Polaroid filter from which the animated version depend

Anyway i suggested the change to David, not really to allow step resize but because can add flexibility when doing animations

PS i see now for what you planned to use
Have a look in Gmic to Array/Tunnel

_________________
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
 Post subject: Re: FU-stair-resize.scm
PostPosted: Sun Apr 03, 2011 9:04 pm  (#13) 
Offline
GimpChat Member
User avatar

Joined: Mar 02, 2011
Posts: 1852
Location: Michigan
Oh hurray another Script I can love :D


Going to bed, I'll spend some quality time with this tomorrow :D

_________________
Image
I'm back I think


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

Joined: May 16, 2010
Posts: 13488
Location: "Looking for my eraser" =P
Awesome Willy!

Yeah PC this is what i was needing.But not for a tunnel effect which does look pretty cool.
I wanted to be able to create a bunch of different sized images on the same canvas for printing. :)
Now after running the script i can just rotate each image and enlarge the canvas to accommodate.

Picture Package works good for this except it creates 2 of one size and 3 of another on the same canvas.I fi could have edited the code for that plug-in to add some settings like 1 this size/1 this size/1 this size - then it would have been okay.

This script is exactly what i needed to accomplish my task.
Thanks again Rob - Golden award is on its way! :P

_________________
Image


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

Joined: May 16, 2010
Posts: 13488
Location: "Looking for my eraser" =P
Image

_________________
Image


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

Joined: Apr 30, 2010
Posts: 1937
Location: Missouri
sorry, script fu

_________________
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
 Post subject: Re: FU-stair-resize.scm
PostPosted: Sun Apr 03, 2011 11:51 pm  (#17) 
Offline
GimpChat Member
User avatar

Joined: Oct 06, 2010
Posts: 2940
Gms9810, try here, where I started a thread:

viewtopic.php?f=9&t=1226&hilit=scheme

I'm currently following some of Fencepost's tutorials using the console.

_________________
Image


"In order to attain the impossible, one must attempt the absurd."
~ Miguel de Cervantes


Top
 Post subject: Re: FU-stair-resize.scm
PostPosted: Mon Apr 04, 2011 8:12 am  (#18) 
Offline
GimpChat Member
User avatar

Joined: Mar 02, 2011
Posts: 1852
Location: Michigan
Rod wrote:
Image

And I thought I was a script head :lol

Looks good Rod very cool animation :D

_________________
Image
I'm back I think


Top
 Post subject: Re: FU-stair-resize.scm
PostPosted: Mon Apr 04, 2011 9:21 am  (#19) 
Offline
GimpChat Member
User avatar

Joined: Mar 02, 2011
Posts: 1852
Location: Michigan
I got a request for this script
Once the image is re-sized down, could you have it reverse the effect, so take your smaller image and scale it up to original size, this would give a really cool animation :D


_________________
Image
I'm back I think


Top
 Post subject: Re: FU-stair-resize.scm
PostPosted: Mon Apr 04, 2011 9:27 am  (#20) 
Offline
GimpChat Member
User avatar

Joined: Oct 07, 2010
Posts: 393
Location: home/Nixnine/.gimp-2.0/scripts/nixnine.scm
You can reverse order by Layer/Stack/Reverse layer order. A couple steps involved, duplicate image, reverse order, then drag and drop reversed layers in original.

_________________
Image
I refuse to be confused, but am often confused at this refusal.


Top
Post new topic Reply to topic  [ 26 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Batch Scripting Resize - Sharpern - Resize help?

13

No new posts Attachment(s) Resize by Area

15

No new posts Attachment(s) Resize and Save Image Rel 4

8

No new posts Playback window resize?

25

No new posts Attachment(s) How do I resize images in GIMP?

8



* Login  



Powered by phpBB3 © phpBB Group