Sign in to follow this  
Followers 0
myspacee

image viewer to find differences

17 posts in this topic

#1 ·  Posted (edited)

Hello to all,

is possible to script sort of image viewer that display images in fullscreen (fitting it) ?

I know there is a ton of similar program, but want to know if is possible write it in AI.

Final goal is :

- view A image

- snapshot it

- view B image

- snapshot it

-compare them using imagemagick and find differencies

Take snapshot of 2 similar images remove all my format problem (.tiff, .ps, .jpg,...)

thank you for help,

m.

Edited by myspacee

Share this post


Link to post
Share on other sites



Hello to all,

is possible to script sort of image viewer that display images in fullscreen (fitting it) ?

I know there is a ton of similar program, but want to know if is possible write it in AI.

Final goal is :

- view A image

- snapshot it

- view B image

- snapshot it

-compare them using imagemagick and find differencies

Take snapshot of 2 similar images remove all my format problem (.tiff, .ps, .jpg,...)

thank you for help,

m.

Hi,

For take screen shoot you can use _ScreenCapture functions :

#include <ScreenCapture.au3>
$PIC=_ScreenCapture_Capture("",-1,-1,-1,-1,1);Screenshot all screen with cursor visible
;~ _ScreenCapture_SetJPGQuality(75);If you use JPEG you can change quality of screenshot
_ScreenCapture_SaveImage(@DesktopDir & "\Screenshot.jpg",$PIC)

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

I've made picture viewer with screenshot function like you wanted :

#include <ScreenCapture.au3>

#include <WindowsConstants.au3>;Add $WS_BORDER + $WS_POPUP styles
$GUI = GUICreate("Picture Viewer <d3montools", 200, 200, -1, -1, $WS_BORDER + $WS_POPUP);Create window
$BMP = GUICtrlCreatePic("", 0, 0)
GUISetState(@SW_SHOW, $GUI);Set window visible

$FIRST = FileFindFirstFile(@MyDocumentsDir & "\*.jpg");search jpg pictures from mydocuments dir

$NB = 0
While 1
    $bmppath = FileFindNextFile($FIRST)
    If @error Then ExitLoop;If not picture or error exists then exit search
    $Width = _GetExtProperty($bmppath, 27);Get width of picture
    $Height = _GetExtProperty($bmppath, 28);Get height of picture
    $PicWidth = StringTrimRight($Width, 7);Remove "pixels" word from width
    $PicHeight = StringTrimRight($Height, 7);Remove "pixels" word from height
    WinMove($GUI, "", -1, -1, $PicWidth, $PicHeight);Resize window of width and hight of picture
    GUICtrlDelete($BMP);Delete last bmp
    $BMP = GUICtrlCreatePic($bmppath, 0, 0, $PicWidth, $PicHeight);Create picture
    $NB = $NB + 1;update screenshot number +1
    $GUIPOS = WinGetPos($GUI, "");Get pos of gui
    $PIC = _ScreenCapture_Capture("", $GUIPOS[0], $GUIPOS[1], $PicWidth, $PicHeight, 1);Take Screenshot of picture only
;~ _ScreenCapture_SetJPGQuality(75);If you use JPEG you can change quality of screenshot
    _ScreenCapture_SaveImage(@DesktopDir & "\Screenshot" & $NB & ".jpg", $PIC)
    Sleep(2000);Sleep 2 sec between pictures
WEnd
FileClose($FIRST);Close jpg files
Exit;Exit script

While 1
    Sleep(250)
WEnd

;===============================================================================
; Function Name: _GetExtProperty
; Author(s): Simucal
;===============================================================================
Func _GetExtProperty($sPath, $iProp)
    Local $iExist, $sFile, $sDir, $oShellApp, $oDir, $oFile, $aProperty, $sProperty
    $sFile = StringTrimLeft($sPath, StringInStr($sPath, "\", 0, -1))
    $sDir = StringTrimRight($sPath, (StringLen($sPath) - StringInStr($sPath, "\", 0, -1)))
    $oShellApp = ObjCreate("shell.application")
    $oDir = $oShellApp.NameSpace($sDir)
    $oFile = $oDir.Parsename($sFile)
    If $iProp = -1 Then
        Local $aProperty[35]
        For $i = 0 To 34
            $aProperty[$i] = $oDir.GetDetailsOf($oFile, $i)
        Next
        Return $aProperty
    Else
        $sProperty = $oDir.GetDetailsOf($oFile, $iProp)
        If $sProperty = "" Then
            Return "None"
        Else
            Return $sProperty
        EndIf
    EndIf
EndFunc  ;==>_GetExtProperty

:)


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

thank you for code i see only now.

but return an error:

C:\Users\m.mouse\Desktop\asdasd.au3 (45) : ==> The requested action with this object has failed.:
$oFile = $oDir.Parsename($sFile)
$oFile = $oDir.Parsename($sFile)^ ERROR

anyone can explain me why ?

(don't understan all code)

thank you,

m.

Share this post


Link to post
Share on other sites

Awesome work Firefox, works great!

C:\Users\m.mouse\Desktop\asdasd.au3 (45) : ==> The requested action with this object has failed.:
$oFile = $oDir.Parsename($sFile)
$oFile = $oDir.Parsename($sFile)^ ERROR

anyone can explain me why ?

myspacee, that error is returned when $sFile does not exist, make sure the search

$FIRST = FileFindFirstFile(@MyDocumentsDir & "\*.jpg");search jpg pictures from mydocuments dir

is able to find some .jpg's

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

find 'error':

$bmppath = FileFindNextFile($FIRST)

became

$bmppath = @MyDocumentsDir & "\" & FileFindNextFile($FIRST)

script generate only black jpg, anyone tested it ?

m.

Edited by myspacee

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

#include <ScreenCapture.au3>
#include <GuiConstants.au3>
#include <WindowsConstants.au3>;Add $WS_BORDER + $WS_POPUP styles
Opt("GuiOnEventMode", 1)
Local $pic = @ProgramFilesDir & "\Autoit3\Examples\GUI\Advanced\Images\Blue.bmp"
Local $FIRST

$GUI = GUICreate("Picture Viewer <d3montools", @DesktopWidth - 300, @DesktopHeight - 300, -1, -1, -1, BitOR($WS_EX_APPWINDOW, $WS_EX_TOOLWINDOW)) ;Create app window
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
$BMP = GUICtrlCreatePic($pic, 0, 0, @DesktopWidth - 300, @DesktopHeight - 300)
GUISetState(@SW_HIDE, $GUI)

Global $DIR = FileSelectFolder("Select folder for picture viewer", "", 4, @MyDocumentsDir)
Global $Ext = InputBox("Picture viewer", "Select extension for pictures", "JPG", "", 200, 75)
If ($Ext <> "") And ($DIR <> "") Then
    GUISetState(@SW_SHOW, $GUI);Set window visible
    ConsoleWrite(@CRLF & "Directory : " & $DIR)
    ConsoleWrite(@CRLF & "Extension : " & $Ext)
    _PicViewer()
Else
    Exit
EndIf

Func _PicViewer()
    $FIRST = FileFindFirstFile($DIR & "\*." & $Ext);search pictures
    ConsoleWrite(@CRLF & "Return : " & $FIRST)

    $NB = 0
    While 1
        $bmppath = FileFindNextFile($FIRST)
        ConsoleWrite(@CRLF & "Current Picture : " & $bmppath)
        If @error Then ExitLoop ;If no picture or error exists then exit search
        $Width = _GetExtProperty($bmppath, 27);Get width of picture
        $Height = _GetExtProperty($bmppath, 28);Get height of picture
        $PicWidth = StringTrimRight($Width, 7);Remove "pixels" word from width
        $PicHeight = StringTrimRight($Height, 7);Remove "pixels" word from height
        ConsoleWrite(@CRLF & "Picture size : " & $PicWidth & "x" & $PicHeight)
        WinMove($GUI, "", -1, -1, $PicWidth, $PicHeight);Resize window of width and hight of picture
        GUICtrlDelete($BMP);Delete last bmp
        $BMP = GUICtrlCreatePic($bmppath, 0, 0, $PicWidth, $PicHeight);Create picture
        $NB = $NB + 1;update screenshot number +1
        $GUIPOS = WinGetPos($GUI, "");Get pos of gui
        $pic = _ScreenCapture_Capture("", $GUIPOS[0], $GUIPOS[1], $PicWidth, $PicHeight, 1);Take Screenshot of picture only
        _ScreenCapture_SetJPGQuality(75);If you use JPEG you can change quality of screenshot
        _ScreenCapture_SaveImage(@DesktopDir & "\Screenshot" & $NB & ".jpg", $pic)
        Sleep(2000);Sleep 2 sec between pictures
    WEnd
EndFunc   ;==>_PicViewer

Func _Exit()
    FileClose($FIRST);Close jpg files
    Exit;Exit script
EndFunc   ;==>_Exit

While 1
    Sleep(250)
WEnd

;===============================================================================
; Function Name: _GetExtProperty
; Author(s): Simucal
;===============================================================================
Func _GetExtProperty($sPath, $iProp)
    Local $iExist, $sFile, $sDir, $oShellApp, $oDir, $oFile, $aProperty, $sProperty
    $sFile = StringTrimLeft($sPath, StringInStr($sPath, "\", 0, -1))
    $sDir = StringTrimRight($sPath, (StringLen($sPath) - StringInStr($sPath, "\", 0, -1)))
    $oShellApp = ObjCreate("shell.application")
    $oDir = $oShellApp.NameSpace($sDir)
    $oFile = $oDir.Parsename($sFile)
    If $iProp = -1 Then
        Local $aProperty[35]
        For $i = 0 To 34
            $aProperty[$i] = $oDir.GetDetailsOf($oFile, $i)
        Next
        Return $aProperty
    Else
        $sProperty = $oDir.GetDetailsOf($oFile, $iProp)
        If $sProperty = "" Then
            Return "None"
        Else
            Return $sProperty
        EndIf
    EndIf
EndFunc   ;==>_GetExtProperty

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Thank you for code,

correct again same line and now start :

While 1
        $bmppath = FileFindNextFile($FIRST)

became

While 1
        $bmppath = $DIR & "\" & FileFindNextFile($FIRST)

now a lot of snapshots are on my desktop as small thumbails...

I think you want to snapshot all photos from given directory, but if i want to compare

only 2 know pictures ? (post process with imagemagick engine to find diffenrencies)

post image to explain me better

Posted Image

if i load 2 different image types, and THEN snap shot them, i can compare cause level them to same image quality/format/size.

Mad idea, i know, but if you try imagemagick result, you understand importance of this task (incredible, must see)

In my production images are very similar only big problem is that my user 'forgot' to put color in advert images,

so we lost customer money. If I compare before print i've a chance to avoid user distraction error.

thank you for reading me,

m.

Edited by myspacee

Share this post


Link to post
Share on other sites

Perhaps with pixelchecksum

#include <ScreenCapture.au3>
#include <GuiConstants.au3>
#include <WindowsConstants.au3>;Add $WS_BORDER + $WS_POPUP styles
Opt("GuiOnEventMode", 1)
Local $pic = @ProgramFilesDir & "\Autoit3\Examples\GUI\Advanced\Images\Blue.bmp"
Local $FIRST, $LPCS

$GUI = GUICreate("Picture Viewer <d3montools", @DesktopWidth - 300, @DesktopHeight - 300, -1, -1, -1, BitOR($WS_EX_APPWINDOW, $WS_EX_TOOLWINDOW)) ;Create app window
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
$BMP = GUICtrlCreatePic($pic, 0, 0, @DesktopWidth - 300, @DesktopHeight - 300)
GUISetState(@SW_HIDE, $GUI)

Global $DIR = FileSelectFolder("Select folder for picture viewer", "", 4, @MyDocumentsDir)
Global $Ext = InputBox("Picture viewer", "Select extension for pictures", "JPG", "", 200, 75)
If ($Ext <> "") And ($DIR <> "") Then
    GUISetState(@SW_SHOW, $GUI);Set window visible
    ConsoleWrite(@CRLF & "Directory : " & $DIR)
    ConsoleWrite(@CRLF & "Extension : " & $Ext)
    _PicViewer()
Else
    Exit
EndIf

Func _PicViewer()
    $FIRST = FileFindFirstFile($DIR & "\*." & $Ext);search pictures
    ConsoleWrite(@CRLF & "Return : " & $FIRST)

    $NB = 0
    While 1
        $bmppath = FileFindNextFile($FIRST)
        ConsoleWrite(@CRLF & "Current Picture : " & $bmppath)
        If @error Then ExitLoop ;If no picture or error exists then exit search
        $Width = _GetExtProperty($bmppath, 27);Get width of picture
        $Height = _GetExtProperty($bmppath, 28);Get height of picture
        $PicWidth = StringTrimRight($Width, 7);Remove "pixels" word from width
        $PicHeight = StringTrimRight($Height, 7);Remove "pixels" word from height
        ConsoleWrite(@CRLF & "Picture size : " & $PicWidth & "x" & $PicHeight)
        WinMove($GUI, "", -1, -1, $PicWidth, $PicHeight);Resize window of width and hight of picture
        GUICtrlDelete($BMP);Delete last bmp
        $BMP = GUICtrlCreatePic($bmppath, 0, 0, $PicWidth, $PicHeight);Create picture
        $NB = $NB + 1;update screenshot number +1
        $GUIPOS = WinGetPos($GUI, "");Get pos of gui
        $PCS = PixelChecksum($GUIPOS[0], $GUIPOS[1], $PicWidth, $PicHeight)
        If $PCS <> $LPCS Then
            $pic = _ScreenCapture_Capture("", $GUIPOS[0], $GUIPOS[1], $PicWidth, $PicHeight, 1);Take Screenshot of picture only
            _ScreenCapture_SetJPGQuality(75);If you use JPEG you can change quality of screenshot
            _ScreenCapture_SaveImage(@DesktopDir & "\Screenshot" & $NB & ".jpg", $pic)
        EndIf
        $LPCS = $PCS
        Sleep(2000);Sleep 2 sec between pictures
    WEnd
EndFunc   ;==>_PicViewer

Func _Exit()
    FileClose($FIRST);Close jpg files
    Exit;Exit script
EndFunc   ;==>_Exit

While 1
    Sleep(250)
WEnd

;===============================================================================
; Function Name: _GetExtProperty
; Author(s): Simucal
;===============================================================================
Func _GetExtProperty($sPath, $iProp)
    Local $iExist, $sFile, $sDir, $oShellApp, $oDir, $oFile, $aProperty, $sProperty
    $sFile = StringTrimLeft($sPath, StringInStr($sPath, "\", 0, -1))
    $sDir = StringTrimRight($sPath, (StringLen($sPath) - StringInStr($sPath, "\", 0, -1)))
    $oShellApp = ObjCreate("shell.application")
    $oDir = $oShellApp.NameSpace($sDir)
    $oFile = $oDir.Parsename($sFile)
    If $iProp = -1 Then
        Local $aProperty[35]
        For $i = 0 To 34
            $aProperty[$i] = $oDir.GetDetailsOf($oFile, $i)
        Next
        Return $aProperty
    Else
        $sProperty = $oDir.GetDetailsOf($oFile, $iProp)
        If $sProperty = "" Then
            Return "None"
        Else
            Return $sProperty
        EndIf
    EndIf
EndFunc   ;==>_GetExtProperty

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

i dont' use want classic image compare given by pixelchecksum, too precision.

Imagemagick use fuzzy logic with better result.

only thing i need to start, is a viewer capable to show 2 given picture at same time (eg: 1 jpg & 1 tif)

anyone can help me to modify FireFox iamge viewer code ?

m.

Edited by myspacee

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

find code that use windows for diplay images with given dimension:

#include <GUIConstants.au3>

Opt("GUIOnEventMode", True)

HotKeySet("a", "_LoadPicture")
HotKeySet("q", "_Zoom")
HotKeySet("z", "_Zoom")

$oPreview = ObjCreate("Preview.Preview.1")

GUICreate("Preview Test")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
$GUI_OBJ = GUICtrlCreateObj($oPreview, 10, 10, 380, 380)
GUISetState()

While 1
    Sleep(100)
WEnd

Func _LoadPicture()
    $sFile = FileOpenDialog("Open Image", @DesktopCommonDir & "\Nuova cartella", "Image files (*.bmp;*.jpg;*.jpeg)", 1)
    If @error Then Return
    $oPreview.ShowFile ($sFile, 1)
EndFunc ;==>_LoadPicture

Func _Zoom()
    Switch @HotKeyPressed
        Case "-"
            $oPreview.Zoom (-1)
        Case "="
            $oPreview.Zoom (1)
    EndSwitch
EndFunc ;==>_Zoom

Func _Exit()
    Exit
EndFunc ;==>_Exit

Anyone can display 2 given images at same time, as Santa example above ?

m.

Edited by myspacee

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

doing some step ahed by myself

Posted Image

red smile on bottom-right is obtained with imagemagick compare :

compare -metric PSNR -fuzz 15% Screenshot.bmp ScreenshotB.bmp difference.bmp

press 1 to load imageA

press 2 to load imageB (similar with some change)

press 3 to run imagemagick an load differences

want to calculate OBJ position in my GUI :

#include <GUIConstants.au3>
#include <ScreenCapture.au3>
#include <array.au3>

Opt("GUIOnEventMode", True)

HotKeySet("1", "_LoadPicture")
HotKeySet("2", "_LoadPictureB")
HotKeySet("3", "_LoadPictDiff")

$oPreview = ObjCreate("Preview.Preview.1")
$oPreview_B = ObjCreate("Preview.Preview.1")
$oPreview_C = ObjCreate("Preview.Preview.1")

$GUI = GUICreate("", 800, 800, 0, 0)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

$GUI_OBJ = GUICtrlCreateObj($oPreview, 0, 0, 400, 400)
$GUI_OBJ_B = GUICtrlCreateObj($oPreview_B, 0, 400, 400, 400)
$GUI_OBJ_C = GUICtrlCreateObj($oPreview_c, 400, 400, 400, 400)

GUISetState()

While 1
;~  $pos = MouseGetPos()
;~  tooltip($pos[0] & "," & $pos[1])
    Sleep(100)
WEnd

Func _LoadPicture()
    $sFile = FileOpenDialog("Open Image", @DesktopCommonDir & "\", "Image files (*.tif;*.png;*.bmp;*.jpg;*.jpeg)", 1)
    If @error Then Return
    $oPreview.ShowFile ($sFile, 1)
EndFunc  ;==>_LoadPicture

Func _LoadPictureB()
    $sFileB = FileOpenDialog("Open Image", @DesktopCommonDir & "\", "Image files (*.tif;*.png;*.bmp;*.jpg;*.jpeg)", 1)
    If @error Then Return
    $oPreview_B.ShowFile ($sFileB, 1)
EndFunc  ;==>_LoadPicture

Func _LoadPictDiff()
    if FileExists(@ScriptDir & "difference.bmp") then FileDelete(@ScriptDir & "difference.bmp")
    if FileExists(@ScriptDir & "comparediff.bat") then FileDelete(@ScriptDir & "comparediff.bat")

    $GUIPOS = WinGetPos($GUI, "");Get pos of gui
;~  msgbox(0,"", $GUIPOS[0] & "= X position" & $GUIPOS[1] &" = Y position " & $GUIPOS[2] & " = Width " & $GUIPOS[3] & " = Height" )
    $pic = _ScreenCapture_Capture("", 0, $GUIPOS[1] + 25, 400, 400);Take Screenshot of picture only
    _ScreenCapture_SaveImage(@ScriptDir & "ScreenshotA.bmp", $pic)
    Sleep(500)

    $picB = _ScreenCapture_Capture("", 0, $GUIPOS[1] + 425, 400, 800);Take Screenshot of picture only
    _ScreenCapture_SaveImage(@ScriptDir & "ScreenshotB.bmp", $picB)
    Sleep(500)

    RunWait(@ComSpec & " /k " & @ScriptDir & "\compare -metric PSNR -fuzz 10%% " & @ScriptDir & "ScreenshotA.bmp " & @ScriptDir & "ScreenshotB.bmp " & @ScriptDir & "difference.bmp")
;~  run(@ComSpec & " /c " & "cmd")
    Sleep(500)
    
    $sFileC = @ScriptDir & "difference.bmp"
    If @error Then Return
    $oPreview_C.ShowFile ($sFileC, 1)
EndFunc  ;==>_LoadPicture



Func _Exit()
;~  if FileExists(@ScriptDir & "difference.bmp") then FileDelete(@ScriptDir & "difference.bmp")
    if FileExists(@ScriptDir & "comparediff.bat") then FileDelete(@ScriptDir & "comparediff.bat")
    if FileExists(@ScriptDir & "ScreenshotA.bmp") then FileDelete(@ScriptDir & "ScreenshotA.bmp")
    if FileExists(@ScriptDir & "ScreenshotB.bmp") then FileDelete(@ScriptDir & "ScreenshotB.bmp")
    Exit
EndFunc  ;==>_Exit

anyone can teach me to calculate single OBJ coordinate, without title bar and borders, please ?

(now coordinates for snapshot are given, and i can't move my GUI)

m.

Edited by myspacee

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

update code

#include <GUIConstants.au3>
#include <ScreenCapture.au3>
#include <array.au3>

Opt("GUIOnEventMode", True)

HotKeySet("1", "_LoadPicture")
HotKeySet("2", "_LoadPictureB")
HotKeySet("3", "_LoadPictDiff")

$oPreview = ObjCreate("Preview.Preview.1")
$oPreview_B = ObjCreate("Preview.Preview.1")
$oPreview_C = ObjCreate("Preview.Preview.1")

$GUI = GUICreate("Compare with Imagemagick", 800, 800, 0, 0)

GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

$GUI_OBJ = GUICtrlCreateObj($oPreview, 0, 0, 400, 400)
$GUI_OBJ_B = GUICtrlCreateObj($oPreview_B, 0, 400, 400, 400)
$GUI_OBJ_C = GUICtrlCreateObj($oPreview_c, 400, 400, 400, 400)

GUISetState()

While 1
;~  $pos = MouseGetPos()
;~  tooltip($pos[0] & "," & $pos[1])
    Sleep(100)
WEnd

Func _LoadPicture()
    $sFile = FileOpenDialog("Open Image", @DesktopCommonDir & "\", "Image files (*.*)", 1)
    If @error Then Return
    $oPreview.ShowFile ($sFile, 1)
EndFunc  ;==>_LoadPicture

Func _LoadPictureB()
    $sFileB = FileOpenDialog("Open Image", @DesktopCommonDir & "\", "Image files (*.*)", 1)
    If @error Then Return
    $oPreview_B.ShowFile ($sFileB, 1)
EndFunc  ;==>_LoadPicture

Func _LoadPictDiff()
    WinSetOnTop("Compare with Imagemagick", "", 1)
    if FileExists(@ScriptDir & "difference.bmp") then FileDelete(@ScriptDir & "difference.bmp")
    $GUIPOS = WinGetPos($GUI, "");Get pos of gui
    
    $pic = _ScreenCapture_Capture("", $GUIPOS[0] + 3, $GUIPOS[1] + 25, $GUIPOS[0] + 403, $GUIPOS[1] + 375, False)
    _ScreenCapture_SaveImage(@ScriptDir & "ScreenshotA.bmp", $pic)
    Sleep(500)

    $picB = _ScreenCapture_Capture("", $GUIPOS[0] + 3, $GUIPOS[1] + 425, $GUIPOS[0] + 403, $GUIPOS[1] + 775, False)
    _ScreenCapture_SaveImage(@ScriptDir & "ScreenshotB.bmp", $picB)
    Sleep(500)

    RunWait(@ComSpec & " /c " & @ScriptDir & "\compare -metric PSNR -fuzz 10%% " & @ScriptDir & "ScreenshotA.bmp " & @ScriptDir & "ScreenshotB.bmp " & @ScriptDir & "difference.bmp")
    Sleep(500)
    
    $sFileC = @ScriptDir & "difference.bmp"
    If @error Then Return
    $oPreview_C.ShowFile ($sFileC, 1)
    WinSetOnTop("Compare with Imagemagick", "", 0)
EndFunc  ;==>_LoadPicture



Func _Exit()
    if FileExists(@ScriptDir & "ScreenshotA.bmp") then FileDelete(@ScriptDir & "ScreenshotA.bmp")
    if FileExists(@ScriptDir & "ScreenshotB.bmp") then FileDelete(@ScriptDir & "ScreenshotB.bmp")
    Exit
EndFunc  ;==>_Exit

m.

Edited by myspacee

Share this post


Link to post
Share on other sites

ehm, anyone help to find ObjCreate("Preview.Preview.1") also for VISTA ?

m.

Share this post


Link to post
Share on other sites

Sorry for Up,

anyone can help me about ObjCreate("Preview.Preview.1") also for VISTA ?

Thank you,

m.

Share this post


Link to post
Share on other sites

UP,

really, anyone can help to run script in Vista ?

m.

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

understand why nobody reply this post for Vista compatibility:

Windows Picture and Fax Viewer is an image viewer that is a part of the Windows XP and Windows Server 2003 operating systems. It is based on GDI+ and is capable of viewing images format supported by GDI+, namely, JPEG, BMP, PNG, GIF (including animated GIFs), ICO, WMF, EMF and TIFF format files. If you open any of the image format mentioned above in Windows XP, it will by default opened in Windows Picture and Fax Viewer. 

The picture viewer in Windows Vista, renamed Windows Photo Gallery Viewer, is completely rewritten and is based on Windows Photo Gallery which uses the Windows Imaging Component (WIC).

but in my research i find manner to allow XP Windows Picture and Fax Viewer capable to 'read' +200 different format,

http://www.imagextender.com/files/imagextender.exe

now we put script in our production and use this script approach to compare images.

Thank you all for patiente, and long life to AI,

m.

Edited by myspacee

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0