' ------------------------------------------------------------------------------------ ' Start_StereoView.vbs ' ' This script will launch the StereoVue*|*3D / StereoView application. ' Select the first picture of the pair (the left one) and start the script. StereoVue ' will start and load the left and right pictures. ' Offset information is written back in the "Offset" Custom Field of the right picture ' allowing the alignment done in StereoVue to be stored in the album. ' StereoVue is available at: http://ggrillot.free.fr/stereovue ' ------------------------------------------------------------------------------------ Option Explicit Const svPath = "M:\Program Files\StereoVue\StereoVue.exe" ' Replace by the full path of the application 'Const svPath = "D:\HTML\StereoScope\stereoview\StereoView.exe" ' Replace by the full path of the application 'Const svComment = "%C1 %C2" Const ForReading = 1, ForWriting = 2 const JPS_RATIO = 2.2 app.ClearTrace Dim alb, pic, pic1, pic2, sCmd, fso, f, outputFileName, s, T, xO, yO, xO2, yO2, bSinglePix, bJPS, nRunMode, bHasSpace Set fso = CreateObject("Scripting.FileSystemObject") outputFileName = left( svPath, InStrRev( svPath, "\" ) ) & "_sv_.prm" bHasSpace = False if InStr( svPath, " " ) > 0 then bHasSpace = True set alb = app.GetCurrentAlbum bSinglePix = True '(alb.nbSelectedPicture <= 2) nRunMode = 1 if bSinglePix then set pic1 = alb.GetVisiblePicture( alb.nCurrentPicture ) set pic2 = alb.GetVisiblePicture( alb.nCurrentPicture+1 ) bJPS = CheckForJPS( pic1 ) app.Trace "JPS mode is: " & bJPS if not bJPS then GetPictureOffset pic2, xO, yO s = -xO & "," & yO app.Trace "Current offset = " & xO & "," & yO end if ' Build a parameter file for StereoView Set f = fso.OpenTextFile( outputFileName, ForWriting, True ) if not bJPS then f.WriteLine "[StereoView]" f.WriteLine "version=Pré Version : 0.57" f.WriteLine "fichier=Parametres" f.WriteLine "" f.WriteLine "[Stereo]" f.WriteLine "type=1" f.WriteLine "" f.WriteLine "[Left]" f.WriteLine "filename=" & alb.ExpandMacro( pic1, "%RP" ) f.WriteLine "posx=0" f.WriteLine "posy=0" f.WriteLine "" f.WriteLine "[Right]" f.WriteLine "filename=" & alb.ExpandMacro( pic2, "%RP" ) f.WriteLine "posx=" & xO f.WriteLine "posy=" & yO 'f.WriteLine "21,36000,0," & s & "," & alb.ExpandMacro( pic1, "%RP" ) & "," & alb.ExpandMacro( pic2, "%RP" ) & ",," nRunMode = &h10001 else s = "0,0" f.WriteLine "11,36000,0," & s & "," & alb.ExpandMacro( pic1, "%RP" ) & ",,," end if f.Close sCmd = "" if bHasSpace then sCmd = sCmd & """" sCmd = sCmd & svPath if bHasSpace then sCmd = sCmd & """" sCmd = sCmd & " 10 " if bHasSpace then sCmd = sCmd & """" sCmd = sCmd & outputFileName if bHasSpace then sCmd = sCmd & """" app.Trace "Command is: >>" & sCmd & "<<" app.Run sCmd, False, nRunMode if not bJPS then Set f = fso.OpenTextFile( outputFileName, ForReading, True ) Dim nFound nFound = 0 while nFound <> 3 and not f.AtEndOfStream s = f.ReadLine if s = "[Right]" then nFound = 1 if nFound = 1 and left(s,5) = "posx=" then xO2 = CInt(CDbl(replace(mid(s, 6),".",","))) nFound = 2 end if if nFound = 2 and left(s,5) = "posy=" then yO2 = CInt(CDbl(replace(mid(s, 6),".",","))) nFound = 3 end if wend f.Close app.Trace xO & "," & yO app.Trace xO2 & "," & yO2 if xO <> xO2 or yO <> yO2 then s = xO2 & "," & yO2 app.Trace "New offset = " & s pic2.SetCustomField "Offset", s end if end if end if app.Trace "Done!", -1, TRACE_OK sub GetPictureOffset( byref pix, byref xP, byref yP) dim s, T if pix is Nothing then s = "" else s = pix.GetCustomField( "Offset" ) end if 'app.Trace "Current offset = " & s if s = "" then s = "0,0" T = Split( s, ",", -1, 1 ) xP = CInt(T(0)) yP = CInt(T(1)) end sub function CheckForJPS( byref pic ) ' A JPS picture (side-by-side) is generally much larger than usual ' so we guess if it's a JPS when the width is more than JPS_RATIO times the height CheckForJPS = False if LCase(right(pic.sShortFileName,4)) = ".jps" then CheckForJPS = TRUE elseif pic.w > pic.h * JPS_RATIO then CheckForJPS = TRUE end if end function