AutoHotkey Community

It is currently May 26th, 2012, 10:29 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: September 3rd, 2009, 10:50 pm 
Offline

Joined: November 3rd, 2004, 8:43 pm
Posts: 34
Most photographers recommend the "Rule-of-Thirds" to assist with the composition of photos and several digital cameras now offer the option of a grid on the camera screen for this purpose. I developed this simple script to display a resizable overlay grid to assist with editing / cropping photos in IrfanView. It can probably be used equally effectively with other image editors. I'm sure that the script can be improved tremendously by more experienced AutoHotKey users.

SplashImage apparently will only scale up an image and will crop it if you scale down below the original size. Accordingly, I have created a 600 x 300 grid for use with this script. This image can be created by drawing 600 long horizantal lines at row y100 and y200 and two 300 long vertical lines at x200 and x400. This image should be called GridOverlay.jpg and should be placed in the same directory as the script.

After installing and running the script press Shift+F1 to display a help screen.


Code:
; Create SplashImage window to display edit grid for IrfanView
; v1.0 by Martin O'Neill 23-Aug-2009

ScaleWidth := A_ScreenWidth    ; Full screen width initially
ScaleHeight := A_ScreenHeight -100   ; Full screen ht. initially less 100 for tool & status bars
Gosub, ShowGrid

ShowGrid:      ; Begin Gosub section
#Persistent      ; Ensures that image stays on screen
SplashImage, %A_ScriptDir%\GridOverlay.jpg, Y80 ZW%ScaleWidth% ZH%ScaleHeight% B1
; jpg file must be placed in same directory as script
; Y80 = begin at row 80 i.e. Y coordinate; ZW%ScaleWidth% sets scaled width of grid
; ZHScaleHeight sets scaled height of grid
; B = No Border or Title, B1 = thin border
WinSet, TransColor, White, SplashGrid.ahk ; Make all white pixels invisible or transparent
Return

; MESSAGE BOX LIST OF HOT KEYS
+F1::         ; Shift+F1 - show help
gui, font, Arial Bold S11
Gui, Add, Text, , Shift+F1 - show help`nShift+Esc = to turn grid off but leave script running`nCtrl+g = turn grid on again`nShift+Right Arrow key = increase grid width`nShift+Left Arrow key = decrease grid width`nShift+Down Arrow key = increase grid height`nShift+Up Arrow key = decrease grid height`nCtrl+Shift+x to exit script`n`nFor best use images should be centred on screen

Gui, add, button, default xm, Cancel  ; xm puts it at the bottom left corner.
Gui, Show, x270 y110, Hot Keys Help
Sleep 20000
GuiEscape:
GuiClose:
ButtonCancel:
Gui, Cancel ; All of the above labels will execute this subroutine.
return


; HOT KEYS SECTION
+ESC::   ; Shift+Esc to turn grid off but leave script running
   Splashimage, Off
   SplashImage,, W150 H100 B1,, Turning Off Grid`n`nCtrl+g `nto turn on again,
   Sleep 1500
   Splashimage, Off
   ; ToolTip
return

^G::   ; Ctrl+g to turn grid on again
   SplashImage,, W150 H100 B1,, Turning On Grid`n`nShift+Esc `nto turn off again,
   Sleep 1500
   Splashimage, Off
   Gosub, ShowGrid
Return

+Right::   ; Shift+Right to increase grid width
   ScaleWidth := Scalewidth+100   ; := must be used to change variable and %n% then not required
   Splashimage, Off
   Gosub, ShowGrid
Return

+Left::   ; Shift+Left to decrease grid width
   ScaleWidth := Scalewidth-100
   Splashimage, Off
   Gosub, ShowGrid
Return

+Up::   ; Shift+Up to decrease grid ht.
   ScaleHeight := ScaleHeight -100
   Splashimage, Off
   Gosub, ShowGrid
Return

+Down::   ; Shift+Down to increase grid ht.
   ScaleHeight := ScaleHeight +100
   Splashimage, Off
   Gosub, ShowGrid
Return

^+X::      ; Ctrl+Shift+x to Exit script
   ExitApp
Return




Enjoy

Martin[/img]


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Cristi®, Google Feedfetcher, Yahoo [Bot] and 10 guests


You can post new topics in this forum
You can 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:
Powered by phpBB® Forum Software © phpBB Group