Search code examples
imagemagickjpeggraphicsmagickwebpssim

SSIM calculation for WebP


ImageMagick's 'compare' seems to provide irrelevant numbers when using SSIM as the comparison metric. I'm using ImageMagick 7.0.8-58 Q16.

I tried it with various levels of WebP compression (including lossless)

magick compare -metric SSIM original.png lossless.webp difference.png

provides 0.734809. While I would expect something around 0.999 for a visually indistinguishable image (apparently no artifacts, because it's a WebP file compressed in lossless mode)

Receiving such results, I assumed that there is a problem with comparing PNG to WebP specifically, so I tried to compare original PNG to compressed JPEG with a target SSIM. SSIM package from Fred's ImageMagick Scripts gave results of ssim=0.949 and dssim=0.051. ImageMagick on contrary gave 0.711049 result for the very same file.

magick compare -metric SSIM original.png compressed.jpg difference.png

Sadly, Fred's SSIM doesn't seem to work with WebP and GraphicsMagick's compare doesn't support SSIM. So how do I get an accurate SSIM from ImageMagick or what are the other ways to get SSIM for WebP files?


Solution

  • Actually the answer is pretty simple. I used a bugged version of ImageMagick. Just changing the order of comparison did the trick:

    magick compare -metric SSIM compressed.jpg original.png difference.png