diff --git a/src/Intervention/Image/Image.php b/src/Intervention/Image/Image.php index 647e8e53..66f1d342 100644 --- a/src/Intervention/Image/Image.php +++ b/src/Intervention/Image/Image.php @@ -1425,6 +1425,26 @@ class Image return (is_resource($input) && get_resource_type($input) == 'gd'); } + /** + * Checks if the current image has (half) transparent pixels + * + * @return boolean + */ + private function hasTransparency() + { + $step_x = min(max(floor($this->width/50), 1), 10); + $step_y = min(max(floor($this->height/50), 1), 10); + + for ($x=0; $x<$this->width; $x=$x+$step_x) { + for ($y=0; $y<$this->height; $y=$y+$step_y) { + $color = $this->pickColor($x, $y); + if ($color['a'] < 1) return true; + } + } + + return false; + } + /** * Returns image stream *