test ImageMagick to see if two non-identical images are considered identical.

on failure, fall back to diffpng comparison (diffpng.cpp)
master
Don Bright 2014-06-24 23:54:41 -05:00 committed by Marius Kintel
parent b3737d96c2
commit 6f0bd738e7
3 changed files with 20 additions and 5 deletions

View File

@ -504,12 +504,7 @@ add_definitions(${HARFBUZZ_CFLAGS})
# Image comparison - expected test image vs actual generated image
if (DIFFPNG)
# How to set cflags to optimize the executable?
set(IMAGE_COMPARE_EXECUTABLE ${CMAKE_CURRENT_BINARY_DIR}/diffpng)
set(COMPARATOR "diffpng")
add_executable(diffpng diffpng.cpp ../src/lodepng.cpp)
set(SKIP_IMAGEMAGICK 1)
message(STATUS "using diffpng for image comparison")
endif()
if (SKIP_IMAGEMAGICK)
@ -537,8 +532,28 @@ else()
message(STATUS "ImageMagick: OpenMP bug workaround - setting MAGICK_THREAD_LIMIT=1")
set(CTEST_ENVIRONMENT "${CTEST_ENVIRONMENT};MAGICK_THREAD_LIMIT=1")
endif()
message(STATUS "Comparing magicktest1.png with magicktest2.png")
set(IM_TEST_FILES "${CMAKE_CURRENT_SOURCE_DIR}/magicktest1.png" "${CMAKE_CURRENT_SOURCE_DIR}/magicktest2.png")
set(COMPARE_ARGS ${IMAGE_COMPARE_EXECUTABLE} ${IM_TEST_FILES} -alpha Off -compose difference -composite -threshold 10% -morphology Erode Square -format %[fx:w*h*mean] info:)
# compare arguments taken from test_cmdline_tool.py
execute_process(COMMAND ${COMPARE_ARGS} OUTPUT_VARIABLE IM_OUT )
if ( ${IM_OUT} MATCHES "0" )
message(STATUS "magicktest1.png and magicktest2.png were incorrectly detected as identical")
message(STATUS "Using alternative image comparison")
set(DIFFPNG 1)
endif()
endif()
if (DIFFPNG)
# How to set cflags to optimize the executable regardless of CMAKE_BUILD_TYPE?
set(IMAGE_COMPARE_EXECUTABLE ${CMAKE_CURRENT_BINARY_DIR}/diffpng)
set(COMPARATOR "diffpng")
add_executable(diffpng diffpng.cpp ../src/lodepng.cpp)
message(STATUS "Image comparison program: diffpng")
endif()
# Internal includes
include_directories(../src)

BIN
tests/magicktest1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

BIN
tests/magicktest2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB