To illustrate, take this image:
It's ten pixels high with alternating rows of red and green. The hex colors are #990000 and #005500, respectively. Now, take this script:
It makes sure PhotoShop is using pixels and then samples the first pixel of each row. If the ColorSampler worked as expected, the result would be a list of ten lines alternating between '990000' and '005500'. Instead, running it in PhotoShop CS6 (Version 13.0.6) on a MacBook with OS X 10.10 (14A389) produces this:
990000 005500 990000 005500 990000 005500 990000 990000 990000 005500
Everything looks good until just before the end where '990000' occurs three times in a row. That shows the ColorSampler is pulling the color from either row 7 or 9 even though it was assigned to row 8. It's only one error but in programming that's all it takes to render something useless.
I've found a work around to make the ColorSampler trustworthy again. Instead of using integers (e.g.
[10, 0]) for the coordinates, use floats that have an extra tenth of a pixel added on them (e.g.
[10.1, 0.1]). In theory, this doesn't make sense because a pixel is supposed to be the smallest possible unit. Regardless, it works. For example, here's an updated version of the script that adds "0.1" to every row except the last one. (If you add it to the last one it pushes off the canvas and PhotoShop throws an error.)
Running this on the same test image produces the expected output:
990000 005500 990000 005500 990000 005500 990000 005500 990000 005500
And with that, ColorSampler is trustworthy enough to use again. (Though, I'll certainly be keeping a close eye on it.)