开发者

ImageMagick making different images on Windows and Linux

I need a batch process for making mobile images and decided to use ImageMagick, but unfortunately one of my requirements is that the images produced are the same across OS's, since I'm sending them back and forth between my local system (Windows) and the server (Linux). It seems however whenever I call

convert test.jpg -resize 25% test-small.jpg

the process creates different images on both machines. I know this because when I use checksum the values aren't exactly the same.

Does anyone know of any reason why this would happen? And maybe some way around it, either via using a diffe开发者_Python百科rent executable or passing in a parameter that would produce the same images across OS's?


  1. The files have more than the pixels in them -- If you are going to compare the images, write a checksum that works on just the decoded pixel data. That will at least tell you if the images would look the same. The internals of the file could be different because of a lot of factors.

  2. Resizing is dependent on float arithmetic and you can't count on that to be the same across machines. So instead of using just a checksum, you might want to see if each pixel is within a tolerance from the associated one in the other file.

Take a look at these links:

  • http://pdiff.sourceforge.net/
  • http://www.phpied.com/image-diff/


JPEG algorithms are non-deterministic. There is no way to ensure that the same image will be generated across two systems, or even between two invocations on the same system.


Relying on 'checksum' or 'md5sum' or similar to compare two images isn't a wise choice. This can only verify if the files are indeed identical. However, if you have different results, this could be caused by just one byte in some random meta data value being different (like a simple timestamp), while there's no pixel difference at all.

To discover the pixel differences between two images, you can use ImageMagick's compare like this:

compare  image1.jpg  image2.jpg  delta.jpg

For colored input images, the resulting delta.jpg willl use image1.jpb as a light-gray background and display the differences in red color. To get a red+white delta image without the light-gray background, use

compare  image1.jpg  image2.jpg  -compose src  delta.jpg

Examples images of this techniq can be found here:

  • ImageMagick: “Diff” an Image
    Left: Image with text       Center: Original image      Right: Differences (=text) in red pixels.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜