/** * Save an image resource * @param resource $image Image resource * @param string $path File path to save * @param boolean $replace Replace if exists * @return boolean */ public static function _Save($image, $path, $replace = FALSE) { // If a file with the same name already exists if ($replace === FALSE && parent::_Exists($path)) { // new \Sonic\Message ('error', 'An image with this filename already exists: ' . $path); return FALSE; } // Switch new path extension to save file switch (parent::_getExtension($path)) { // gif case 'gif': if (!imagegif($image, $path)) { return FALSE; } break; // png // png case 'png': if (!imagepng($image, $path)) { return FALSE; } break; // default // default default: if (!imagejpeg($image, $path, 80)) { return FALSE; } break; } // Successfully saved, return TRUE return TRUE; }