Bit late to the party but:
GML:
var last_frame_of_animation = image_number - sprite_get_speed(sprite_index)/room_speed;
image_index >= last_frame_of_animation;
This ensures that you are on the last frame of the last sub-image of the sprite animation.
image_index
is the current sub-image of the sprite.
image_number
is the total number of sub-images.
sprite_get_speed(sprite_index)
returns the speed of the sprite as set in the GUI.
room_speed
is the frame rate.
sprite_get_speed(sprite_index)/room_speed
therefore returns the time increments that the image_index changes at. When you minus that from the image number you get the last frame of the last sub-image of the sprite animation. It is only when image_index is greater than or equal to that number that you can be sure you're right at the end of the animation.
Example:
When in a walking state, the player has an image_number of 6 and a speed of 8, and the room_speed is 60fps. So the check goes:
GML:
image_index >= 6 - 8 / 60
Or:
Or:
This way there's no risk of the animation getting chopped slightly early, it allows the 5th part of the animation to play out entirely.