It is currently Thu Apr 25, 2024 5:40 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Mirror image script
PostPosted: Sun Sep 18, 2016 10:18 am  (#1) 
Offline
Script Coder
User avatar

Joined: Apr 13, 2010
Posts: 244
Good morning, All!

I needed a simple script to mirror half an image (L to R, R to L, Top to Bottom, B to T). I couldn't find one elsewhere so I wrote my own. Not sure if anyone would find this valuable, but I'm uploading it here. It's been awhile since I've done any scripting, but I made sure all code is in accordance with the updated scheme for GIMP.

You can find the script at Filters > Render > Mirror Image...

Cheers. Art

Image
(define (mirror-image image drw horv side)
  (let* (
                (originalLayer (car (gimp-image-get-active-layer image)))
     (copyLayer 0)
     (width (car (gimp-drawable-width originalLayer)))
        (height (car (gimp-drawable-height originalLayer)))
    
     (cX (/ width 2))
     (cY (/ height 2))

   
     )

(gimp-image-undo-group-start image)
(gimp-layer-add-alpha originalLayer)
(set! copyLayer (car (gimp-layer-copy originalLayer TRUE)))
(gimp-image-add-layer image copyLayer -1)

(if (= horv 0)
   (begin
   (gimp-image-select-rectangle image CHANNEL-OP-ADD 0 0 cX height)
   (if (= side 0)
      (begin
      (gimp-selection-invert image)      
      (gimp-edit-clear copyLayer)
      (gimp-selection-none image)
      (gimp-item-transform-flip-simple copyLayer ORIENTATION-HORIZONTAL TRUE cX)


      )
      (begin
      (gimp-edit-clear copyLayer)
      (gimp-selection-none image)
      (gimp-item-transform-flip-simple copyLayer ORIENTATION-HORIZONTAL TRUE cX)
      )


   ))
)

(if (= horv 1)
   (begin
   (gimp-image-select-rectangle image CHANNEL-OP-ADD 0 0 width cY)
   (if (= side 0)
      (begin
      (gimp-selection-invert image)      
      (gimp-edit-clear copyLayer)
      (gimp-selection-none image)
      (gimp-item-transform-flip-simple copyLayer ORIENTATION-VERTICAL TRUE cY)


      )
      (begin
      (gimp-edit-clear copyLayer)
      (gimp-selection-none image)
      (gimp-item-transform-flip-simple copyLayer ORIENTATION-VERTICAL TRUE cY)
      )


   ))
)





(gimp-image-merge-down image copyLayer CLIP-TO-IMAGE)
(set! originalLayer (car (gimp-image-get-active-layer image)))









   
; Allow for the GIMP settings to be restored prior to running the script

(gimp-context-push)



(gimp-displays-flush)
(gimp-image-undo-group-end image)

; Return GIMP settings back to those used prior to script

(gimp-context-pop)
   
  )
)

(script-fu-register "mirror-image"
  "<Image>/Filters/Render/Mirror Image..."
  ""
  "Art Wade"
  "Art Wade"
  "September 17, 2016"
  "RGB*"
  SF-IMAGE       "Image"               0
  SF-DRAWABLE    "Drawable"            0
  SF-OPTION       "Horizontal or Vertical?"       '("Horizontal"
                     "Vertical")
  SF-OPTION       "Left or Right (Top or Bottom)?"   '("Left (Top if Vertical)"
                     "Right (Bottom if Vertical)")
)
               

_________________
I'd rate you as an upper-middle-lower-mod with pro-novice-inter tendencies.....and a twist of lime! Of course, my rating scale is completely objectively subjective, but ALWAYS consistently inconsistent.


Last edited by fencepost on Sun Sep 18, 2016 12:45 pm, edited 2 times in total.

Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Mirror image script
PostPosted: Sun Sep 18, 2016 11:15 am  (#2) 
Offline
Global Moderator
User avatar

Joined: Oct 06, 2010
Posts: 4046
Good to see you, Fencepost! Long time no see! I've been using Saulgoode's mirror script, and I will be happy to check yours out!

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


Top
 Post subject: Re: Mirror image script
PostPosted: Sun Sep 18, 2016 11:34 am  (#3) 
Offline
Script Coder
User avatar

Joined: Apr 13, 2010
Posts: 244
Hey, Mahvin! Good to see you as well. Yeah, life kinda got in the way of things and I quit GIMP'ing with the exception of basic photo editing. I saw saulgoode's script and gave it a test, but if I'm not mistaken, I believe it mirrored the entire image and I just needed half of the image.

If they're the same, let me know and we can pull it from here. No need for duplicate scripts. :)

_________________
I'd rate you as an upper-middle-lower-mod with pro-novice-inter tendencies.....and a twist of lime! Of course, my rating scale is completely objectively subjective, but ALWAYS consistently inconsistent.


Top
 Post subject: Re: Mirror image script
PostPosted: Sun Sep 18, 2016 11:50 am  (#4) 
Offline
Global Moderator
User avatar

Joined: Oct 06, 2010
Posts: 4046
No, you are correct in that it mirrors the entire image (I just tested both). So your version is worthwhile appreciated for halving the image.

It's more than worthwhile! My bad - (I need more coffee)

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


Top
 Post subject: Re: Mirror image script
PostPosted: Sun Sep 18, 2016 12:01 pm  (#5) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
Hey it's great to hear from you again Art. Thanks for the new script. Don't be a stranger now. :)
Interesting effects.

Image

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: Mirror image script
PostPosted: Sun Sep 18, 2016 12:22 pm  (#6) 
Offline
Retired Staff
User avatar

Joined: May 22, 2008
Posts: 6947
Location: Somewhere in GIMP
Fencepost!!! How good to see you. :hugme

Had to give your new script a try.

Image


Image


I've attached your script so others can download it.
Find it here: <image> Filters > Render > Mirror Image...


Attachments:
fp-mirror-image.scm [2.3 KiB]
Downloaded 261 times

_________________
Image
World War IV will be fought with sticks and stones. - Albert Einstein
Top
 Post subject: Re: Mirror image script
PostPosted: Sun Sep 18, 2016 12:46 pm  (#7) 
Offline
Script Coder
User avatar

Joined: Apr 13, 2010
Posts: 244
Good to see you, O! Thanks for making it available as an attachment. Been so long since I've used the forum, I've forgotten all the ins/outs! :)

ETA: Hi, Rod! "Don't be a stranger?" I can't get any more strange! LOL

_________________
I'd rate you as an upper-middle-lower-mod with pro-novice-inter tendencies.....and a twist of lime! Of course, my rating scale is completely objectively subjective, but ALWAYS consistently inconsistent.


Last edited by fencepost on Sun Sep 18, 2016 12:48 pm, edited 2 times in total.

Top
 Post subject: Re: Mirror image script
PostPosted: Sun Sep 18, 2016 12:46 pm  (#8) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
Oregonian wrote:
Fencepost!!! How good to see you. :hugme

Had to give your new script a try.

[ Image ]


[ Image ]


I've attached your script so others can download it.
Find it here: <image> Filters > Render > Mirror Image...

Good use of the script O! Looks almost realistic. :bigthup

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: Mirror image script
PostPosted: Sun Sep 18, 2016 1:17 pm  (#9) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
nice to have it as a gimp-only script, but -for those using also g'mic- the function is available under Arrays

input
Attachment:
original.jpg
original.jpg [ 293.61 KiB | Viewed 5206 times ]


screenshot of g'mic
Attachment:
Cattura.PNG
Cattura.PNG [ 403.72 KiB | Viewed 5206 times ]


output
Attachment:
mirrored-50.png
mirrored-50.png [ 1.2 MiB | Viewed 5206 times ]


anyhow, good addition to gimp filters and nice to see you back here

_________________
"Where am I ?"


Top
 Post subject: Re: Mirror image script
PostPosted: Tue Sep 20, 2016 8:42 am  (#10) 
Offline
Script Coder
User avatar

Joined: Apr 13, 2010
Posts: 244
Thank you, dinasset for letting me know about the G'MIC plugin. I wasn't aware of that, and thank you for the welcome.

_________________
I'd rate you as an upper-middle-lower-mod with pro-novice-inter tendencies.....and a twist of lime! Of course, my rating scale is completely objectively subjective, but ALWAYS consistently inconsistent.


Top
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Script OCR Image (Tesseract OCR engine )

5

No new posts Script-fu select outline of image inside png

1

No new posts Error during execution of script, image in inconsistent state

3

No new posts Retexture an image with another image as "Image Pattern" Plug-in

4

No new posts GIMP XCF image plug-in could not open image; File is Not 0 Bytes

4



* Login  



Powered by phpBB3 © phpBB Group