Unified rotate actions in key-handler; use lossless operation based on file type