Comparing ImageSpec #3968
-
Hi, |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
There is not, currently. Comparing metadata is certainly possible, but I don't think we have a built-in way to do it. Adding equal() and hash() to ParamValueList would be a good idea if people want to do this. (🎣 Mackerel!) But it would need some some serious caveats and design choices. Comparing literally is easy, but is that really what you want? Like, if you have two "identical" images saved at different times, and the only place the metadata differs is the DateTime field, are they a match, or aren't they? |
Beta Was this translation helpful? Give feedback.
-
if you are just looking for pixel comparison then: And if you are just looking for pixel hashes then: But yeah, like Larry said, once you start figuring in the metadata it gets tricky. And I guess you asked about the specs, not the actual pixel values, so perhaps all of what I'm saying is not related. |
Beta Was this translation helpful? Give feedback.
-
Thanks for following up. I should have clarified, my workflow is for writing images. I'll try to add more context with an example below:
In the example above, the color i.e. color1, color2 and the checkerboard tile size are part of ImageSpec attributes (we namespace it etc so that it's a known attribute). Is there a better way to achieve this? |
Beta Was this translation helpful? Give feedback.
That's an interesting application. I think your strategy is sound, but currently, you'd need to roll your own. I think this would be great for somebody to add, basically you want several steps:
Add a hash() method to ParamValue that just straightforwardly hashes the name, type, and data values. It probably would also not hurt to also have operator== and != for ParamValue.
Add a hash() method to ParamValueList, which sequentially hashes each ParamValue of the list. Again, it probably would be handy to have == and !=.
2.1. I could see utility in also having options to (a) perform the hashing in sorted order (by attribute name) so that two PVLs that have identical attributes but in dif…