Chciałbym poprawić cień (Linia 71) pod generowanym tekstem. Chciałbym aby był w postaci rozmycia w CSS wygląda on tak: text-shadow: 1px 1px 1px #000, 3px 3px 5px rgb(3, 3, 3);
Jak uzyskać taki sam efekt w poniższym skrypcie?
<?php function hex2rgb($hex) { } else { } //return implode(",", $rgb); // returns the rgb values separated by commas return $rgb; // returns an array with the rgb values } class QuoteImage { var $sourceImg; var $logoImg; var $outImg; var $targetWidth = 500; var $font = 'fonts/gunplay.ttf'; var $fontSize = 20; var $align; var $valign; var $image_name; var $transparentBG; function __construct($image_name, $txt, $colors, $fontSize, $align, $valign, $transparentBG) { $this->image_name = $image_name; $this->transparentBG = $transparentBG; switch($ext) { case 'jpeg': $this->sourceImg = imagecreatefromjpeg($image_name); $name .= '.jpg'; break; case 'jpg': $this->sourceImg = imagecreatefromjpeg($image_name); $name .= '.jpg'; break; case 'gif': $this->sourceImg = imagecreatefromgif($image_name); $name .= '.gif'; break; case 'png': $this->sourceImg = imagecreatefrompng($image_name); $name .= '.png'; break; } $this->image_name = $name; $this->logoImg = imagecreatefrompng(Q.'img/logo.png'); $colorBG = hex2rgb($colors['bg']); $colorText = hex2rgb($colors['text']); $colors['bg'] = imagecolorallocate($this->sourceImg, $colorBG[0],$colorBG[1], $colorBG[2]); $colors['text'] = imagecolorallocate($this->sourceImg, $colorText[0], $colorText[1], $colorText[2]); $colors['shadow'] = imagecolorallocate($this->sourceImg, 51, 51, 51); $this->txt = $txt; $this->font = Q.$this->font; $this->fontSize = $fontSize; $this->colors = $colors; $this->align = $align; $this->valign = $valign; } public function prepare() { $target_height = $this->source_attr['h']; if($this->targetWidth < $this->source_attr['w']) { $scale_ratio = $this->source_attr['w']/$this->targetWidth; $target_height = $this->source_attr['h']*$scale_ratio; } //Create our basic image stream 300x300 pixels $this->outImg = imagecreatetruecolor($this->targetWidth , $target_height); //$this->tempImg = imagecreatetruecolor($this->targetWidth , $target_height); $overlay = imagecreatefrompng(Q.'img/overlay.png'); imagecopyresampled($this->outImg, $this->sourceImg, 0,0,0,0, $this->targetWidth, $target_height, $this->source_attr['w'], $this->source_attr['h']); imagecopyresampled($this->outImg, $overlay, 0,0,0,0, $this->targetWidth, $target_height, 1, 1); } public function alignTxt($line = 0, $align = 'center', $valign = 'middle') { $bbox = imagettfbbox($this->fontSize,0,$this->font,$this->txt[$line]); switch($align) { case 'left': // align left $left = 18; break; // align right case 'right': $left = imagesx($this->outImg)-($bbox[4]+18); break; // align center case 'center': $left = $bbox[0] + (imagesx($this->outImg) / 2) - ($bbox[4] / 2); break; } switch($valign) { case 'top': // align top $top = imagesy($this->logoImg); break; // align bottom case 'bottom': $top = imagesy($this->outImg)-($bbox[5]+$this->fontSize*1.33) - $margin; break; // align middle case 'middle': $top = $bbox[1] + (imagesy($this->outImg) / 2) - ($bbox[5] / 2) - $margin; break; } return $return; } public function insertLogo($align = 'center', $valign = 'middle') { switch($align) { case 'left': // align left $left = 10; break; // align right case 'right': $left = imagesx($this->outImg)-(imagesx($this->logoImg)+10); break; // align center case 'center': break; } switch($valign) { case 'top': // align top $top = 10; break; // align bottom case 'bottom': $top = imagesy($this->outImg) - $margin; break; // align middle case 'middle': break; } return $return; } public function output() { $margin = 0; $logo = $this->insertLogo($this->align, $this->valign); imagecopyresampled($this->outImg, $this->logoImg, $logo['left'],$logo['top'], 0,0, imagesx($this->logoImg), imagesy($this->logoImg), imagesx($this->logoImg), imagesy($this->logoImg)); $margin = imagesy($this->logoImg); for($i=0;$i<count($this->txt);$i++) { $align = $this->alignTxt($i, $this->align, $this->valign); if($i == 0) { $bg_positions = imagettftext($this->outImg, $this->fontSize, 0, $align['left'], $align['top']+ $margin, $this->colors['text'], $this->font, $this->txt[$i]); } else { $bg_positions = imagettftext($this->outImg, $this->fontSize, 0, $align['left'], $margin, $this->colors['text'], $this->font, $this->txt[$i]); } $x = $bg_positions[0]-6; $x1 = $bg_positions[2]+6; $y = $bg_positions[5]-7; $y1 = $bg_positions[3]+7; //$y = if($this->transparentBG == "true") { imagefilledrectangle($this->outImg, $x, $y, $x1, $y1, $this->colors['bg']); } if($i == 0) { if($this->transparentBG == "false") { imagettftext($this->outImg, $this->fontSize, 0, $align['left']+2, $align['top']+ $margin+2, $this->colors['shadow'], $this->font, $this->txt[$i]); } imagettftext($this->outImg, $this->fontSize, 0, $align['left'], $align['top']+ $margin, $this->colors['text'], $this->font, $this->txt[$i]); } else { if($this->transparentBG == "false") { imagettftext($this->outImg, $this->fontSize, 0, $align['left']+2, $margin+2, $this->colors['shadow'], $this->font, $this->txt[$i]); } imagettftext($this->outImg, $this->fontSize, 0, $align['left'], $margin, $this->colors['text'], $this->font, $this->txt[$i]); } //Set the content type $margin = ($y1+$this->fontSize+1); } //header('content-type: image/png'); imagepng($this->outImg, WP_CONTENT_DIR.'/uploads/cytaty/'.$this->image_name); imagedestroy($this->outImg); } } ?>