mirror of
https://github.com/Intervention/image.git
synced 2025-08-30 09:10:21 +02:00
added hasTransparency
This commit is contained in:
@@ -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
|
||||
*
|
||||
|
Reference in New Issue
Block a user