public function computeStyle()
{
$this->load($this->getPath());
$this->resize($this->getWidth());
$nb = $this->getImageWidth() * $this->getImageHeight();
$step = $this->getPixelSize();
$pixels = $this->getColorMap();
$style = " width:0;\n";
$style .= " height:0;\n";
$style .= " box-shadow:\n";
foreach ($pixels as $row => $cols) {
foreach ($cols as $col => $colors) {
$alpha = round($colors["alpha"] / -127 + 1, 1);
if ($alpha) {
$style .= ' ';
$style .= sprintf("%4s", $col * $step) . "px ";
$style .= sprintf("%2s", $row * $step) . "px ";
$style .= $this->getBlur() ? $this->getBlur() . "px " : "0 ";
$style .= $step . "px ";
if ($this->color_type === \Image2Css\Converter::RGBA || $this->color_type === \Image2Css\Converter::BEST && $alpha < 1) {
$style .= "rgba(" . $colors["red"] . "," . $colors["green"] . "," . $colors["blue"] . "," . $alpha . ")";
} else {
$style .= strtoupper('#' . $this->rgb2hexa($colors['red']) . $this->rgb2hexa($colors['green']) . $this->rgb2hexa($colors['blue']));
}
$style .= ",\n";
}
}
}
return preg_replace('/,$/', ';', $style);
}