我需要能够确定在我使用Visual Studio的集成源代码控制的应用程序中对某些图像所做的更改。
我环顾四周,并没有开箱即用的程序。怎么办呢?
答案 0 :(得分:3)
可以使用ImageMagick为您完成此处理。安装后,将此批处理文件添加到系统中的某个位置:
@echo off
REM Have to change to ImageMagick directory so that correct EXEs are selected and DLLs are found.
cd /d "D:\Program Files\ImageMagick-7.0.8-Q16"
set cmp1="%temp%\comp1.png"
set cmp2="%temp%\comp2.png"
set img1=%1
set img2=%2
set batTmp="%temp%\comp.bat"
magick identify -format "set img1width=%%w\nset img1height=%%h\n" %1> %batTmp%
magick identify -format "set img2width=%%w\nset img2height=%%h\n" %2>>%batTmp%
call %batTmp%
if %img1width% == %img2width% (
set width=%img1width%
) else (
if %img1width% lss %img2width% (
set resize1=1
set width=%img2width%
) else (
set resize2=1
set width=%img1width%
)
)
if %img1height% == %img2height% (
set height=%img1height%
) else (
if %img1height% lss %img2height% (
set resize1=1
set height=%img2height%
) else (
set resize2=1
set height=%img1height%
)
)
REM Have to use separate ifs otherwise var assignment will not be seen.
if %resize1%. == 1. (
set img1="%temp%\img1.png"
set /a "dwidth=%width%-%img1width%"
set /a "dheight=%height%-%img1height%"
)
if %resize1%. == 1. (
magick convert %1 -gravity southeast -background red -splice %dwidth%x%dheight% %img1%
)
REM Have to use separate ifs otherwise var assignment will not be seen.
if %resize2%. == 1. (
set img2="%temp%\img2.png"
set /a "dwidth=%width%-%img2width%"
set /a "dheight=%height%-%img2height%"
)
if %resize2%. == 1. (
magick convert %2 -gravity southeast -background red -splice %dwidth%x%dheight% %img2%
)
REM Sets if images are put one on top of the other or side by side.
if %width% leq %height% (
set spacer=2x0
set append=+append
) else (
set spacer=0x2
set append=-append
)
REM Comparing image %img1% and %img2% and outputing to %cmp1%.
magick compare %img1% %img2% %cmp1%
REM Splicing original image 1, original image 2 and compared image next to each
REM other with a YELLOW spacer in between.
REM -splice is applied to each image, placing it at top left. -chop is applied to the entire image.
magick convert %img1% %img2% %cmp1% -background yellow -splice %spacer% %append% -chop %spacer% %cmp2%
REM View image
REM Using start on the image file doesn't wait for the executed programme to terminate
start "" /wait imdisplay %cmp2%
:start "" imdisplay %cmp2%
REM Pause for a second to allow imdisplay time to load the file.
:ping -w 1 -n 2 -S 1.1.1.1 1.1.1.1 > NUL
REM Clean up temp files
del %batTmp%
if not %1 == %img1% del %img1%
if not %2 == %img2% del %img2%
del %cmp1%
del %cmp2%
在第二行,将目录更改为已安装应用程序的位置。
Tools->Options->Source Control->Visual Studio Team Foundation Server
并按Configure User Tools...
。Add
。.png .jpg .bmp
等Operation
保留在Compare
。Command
,请键入批处理文件的完整路径和批处理文件的名称,或按...
按钮并导航到批处理文件。Arguments
可以保留为%1 %2
您现在可以在图像文件之间进行比较。输出从上到下或从左到右(取决于纵横比)显示原始第1图像,原始第2图像和图像比较,红色差异,每个图像用黄线分隔。如果一个图像比另一个图像大,则调整它们的大小,红色作为填充颜色。