Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/PhabricatorImageTransformer.php
| Show First 20 Lines • Show All 327 Lines • ▼ Show 20 Lines | /* -( Saving Image Data )-------------------------------------------------- */ | ||||
| * @return string|null PNG file as a string, or null on failure. | * @return string|null PNG file as a string, or null on failure. | ||||
| * @task save | * @task save | ||||
| */ | */ | ||||
| private static function saveImageDataAsPNG($image) { | private static function saveImageDataAsPNG($image) { | ||||
| if (!function_exists('imagepng')) { | if (!function_exists('imagepng')) { | ||||
| return null; | return null; | ||||
| } | } | ||||
| // NOTE: Empirically, the highest compression level (9) seems to take | |||||
| // up to twice as long as the default compression level (6) but produce | |||||
| // only slightly smaller files (10% on avatars, 3% on screenshots). | |||||
| ob_start(); | ob_start(); | ||||
| $result = imagepng($image, null, 9); | $result = imagepng($image, null, 6); | ||||
| $output = ob_get_clean(); | $output = ob_get_clean(); | ||||
| if (!$result) { | if (!$result) { | ||||
| return null; | return null; | ||||
| } | } | ||||
| return $output; | return $output; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines | |||||