[ci skip] Merge pull request #5434 from xims/patch-3

Update Image_lib to avoid setting file permissions when not needed
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index b9adcd6..a5cb6fb 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -835,7 +835,10 @@
 		imagedestroy($dst_img);
 		imagedestroy($src_img);
 
-		chmod($this->full_dst_path, $this->file_permissions);
+		if ($this->dynamic_output !== TRUE)
+		{
+			chmod($this->full_dst_path, $this->file_permissions);
+		}
 
 		return TRUE;
 	}