There&#x27;s an existing tool that does this and uses mozjpeg.<p>It&#x27;s called jpeg-recompress and is part of the jpeg-archive project on Github.<p>It currently can use mean-pixel-error, SSIM (the default), MS-SSIM and SmallFry (an implementation of the patented algorithm used by the JPEG mini app). So they may be open to adding this new comparison algorithm too.<p>edit: someone already filed an issue asking them to look at it:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;danielgtaylor&#x2F;jpeg-archive&#x2F;issues&#x2F;40" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;danielgtaylor&#x2F;jpeg-archive&#x2F;issues&#x2F;40</a>