Created
July 11, 2014 05:35
-
-
Save cergey-obr/036d80fff4f1acebecb7 to your computer and use it in GitHub Desktop.
Скрипт для получения обесцвеченной версии изображения
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function grayscale($img_path) { | |
$umiImg = new umiFile('.'.$img_path); | |
$gray_name = '/images/gray/'.str_replace('.'.$umiImg->getExt(), '', $umiImg->getFileName()).'_gray.jpg'; | |
if (!file_exists('.'.$gray_name)) { | |
switch ($umiImg->getExt()) { | |
case 'jpg': $img = imagecreatefromjpeg($umiImg->getFilePath()); break; | |
case 'gif': $img = imagecreatefromgif($umiImg->getFilePath()); break; | |
case 'png': $img = imagecreatefrompng($umiImg->getFilePath()); break; | |
} | |
imagefilter($img, IMG_FILTER_GRAYSCALE); | |
imagejpeg($img, '.'.$gray_name, 100); | |
} | |
return $gray_name; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment