Now it works in "emacs -Q", but not with my configuration. To be honest I don't think it's worth coding something final on top of current image-mode's API - it looks under-developed at several points.
a) Is all the "window t" stuff necessary? Does anyone really care what is "shown" in a buffer unless it's displayed in a window?
b) If yes, should "window t" be passed to a public hook?
c) Does (image-get-display-property) have any business asking what buffer is currently selected in the window?
d) Why data is sometimes retrieved from the the buffer (as in (image-get-display-property)), and sometimes from image-mode-winprops-alist (as in (image-mode-winprops))? Is the complexity justified, or is one of the methods "legacy"?
I use image viewers, so I could try re-factoring it, adding H/V centering, improving zooming options, and extending the API.