First patch attempt for lack of imagerotate() on some Linux distros