简体   繁体   English

ImageMagick在Windows和Linux上制作不同的图像

[英]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). 我需要一个批处理来制作移动图像,并决定使用ImageMagick,但不幸的是,我的一个要求是所生成的图像在操作系统中是相同的,因为我在本地系统(Windows)和之间来回发送它们。服务器(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? 也许某种方式,通过使用不同的可执行文件或传入一个参数,可以在OS上产生相同的图像?

JPEG algorithms are non-deterministic. JPEG算法是非确定性的。 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. 无法确保在两个系统之间生成相同的映像,甚至无法确保在同一系统上的两个调用之间生成相同的映像。

  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: 看看这些链接:

Relying on 'checksum' or 'md5sum' or similar to compare two images isn't a wise choice. 依靠'checksum'或'md5sum'或类似比较两个图像不是明智的选择。 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: 要发现两个图像之间的像素差异,您可以像这样使用ImageMagick的compare

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. 对于彩色输入图像,生成的delta.jpg将使用image1.jpb作为浅灰色背景并显示红色差异。 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 : 此技术的示例图像可在此处找到:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM