3

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 different executable or passing in a parameter that would produce the same images across OS's?

Kurt Pfeifle
  • 86,724
  • 23
  • 248
  • 345
jimlamiell
  • 78
  • 5
  • an option is to install a linux virtual machine in your computer, and do the conversions in linux – Eric Fortis Jun 17 '11 at 03:02
  • I've thought of that, you mean like Cygwin? I've been burned by it many times, so I'm really looking for something that spans while being in their separate environment. Strangely when I use jpegtran to optimize my jpegs, it creates the same image for both OS's. I wonder if it has to do with losslessness. I'm not an image processing buff, so this stuff is new to me. – jimlamiell Jun 17 '11 at 03:17
  • I mean using virtualbox or vmplayer, with both you can install linux in windows and run both at the same time. e.g. download an ubuntu iso, and create a new virtual machine. you need to specify the amount of RAM, HD space, and the ubuntu iso image location. – Eric Fortis Jun 17 '11 at 03:34

3 Answers3

1

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.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
1
  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:

Lou Franco
  • 87,846
  • 14
  • 132
  • 192
0

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:

Community
  • 1
  • 1
Kurt Pfeifle
  • 86,724
  • 23
  • 248
  • 345