Update image preview generation code