Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script-FU: Batch rotate script
#1
Question 
I am trying to write a batch rotate script, to rotate a number of images by an angle which is passed to the script.
I have the following, which is successfully registered in Gimp:
Code:
(script-fu-register
  "script-fu-batch_arbitrary_rotate"
  "Batch Rotation"
  ""
  ""
  ""
  ""
  "*"
)

(script-fu-menu-register "script-fu-batch_arbitrary_rotate" "<Image>/Tools/My scripts")

(
define (script-fu-batch_arbitrary_rotate pattern inDegrees)
  (let*
    (
      (filelist (cadr (file-glob pattern 1)))
    )
    (while
      (not (null? filelist))
      (let*
        (
          (filename (car filelist))
          (image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
          (radians ( / (* inDegrees 4 (atan 1.0)) 180)) ;converts angle <inDegrees> to radians
          (gimp-item-transform-rotate image radians FALSE 150 150)
          (drawable (car (gimp-image-get-active-layer image)))
          (gimp-file-save RUN-NONINTERACTIVE image drawable filename filename)
        )
        (set! filelist (cdr filelist))
      )
    )
  )
)

This is called in terminal by (to rotate each image by 35 degrees and save):
Code:
gimp -i -b '(script-fu-batch_arbitrary_rotate "*.png" 35)' -b '(gimp-quit 0)'

The terminal output states: "batch command executed successfully", but the images are not rotated. The files' properties suggest that no operations were performed.

I have racked my brains over this; can anyone help with the above script?
Reply


Messages In This Thread
Script-FU: Batch rotate script - by dnairb - 02-03-2019, 11:37 PM
RE: Script-FU: Batch rotate script - by Ofnuts - 02-04-2019, 05:48 AM
RE: Script-FU: Batch rotate script - by dnairb - 02-04-2019, 06:08 PM
RE: Script-FU: Batch rotate script - by dnairb - 02-04-2019, 01:55 PM
RE: Script-FU: Batch rotate script - by Ofnuts - 02-04-2019, 10:39 PM

Forum Jump: