The code definitely looks good. Is there any chance the image isn't square? If that's the case, I can patch in a resize function, but it'll either have to auto-crop the corner or severely skew the image, if that's what's going on. I might've only tested and used this on square / uniform images and that's probably what's going on here.
Also I'm definitely not against either making an auto-crop or auto-skew function that maybe the user can switch back and forth, if that sounds useful