( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ HEX
HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux mail.thebrand.ai 6.8.0-107-generic #107-Ubuntu SMP PREEMPT_DYNAMIC Fri Mar 13 19:51:50 UTC 2026 x86_64
User: www-data (33)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: /var/www/html/processTextPic.php
<?php

 
    $fontSize = 20;
    $fontColor = "#8892BF";
    $font_color =  "#8892BF";
    $lineHeight = 0;
    $align = "center";
    $text = "Stylish drop-down lists using various CSS techniquesStylish drop-down lists using various CSS techniquesStylish drop-down lists using various CSS techniquesStylish drop-down lists using various CSS techniques";
    $angle = 0;
    $underline = true;
    $fontZ =   'assets/fonts/HelveticaNeueLTStd-Ex.otf'; //font used
    $background = "san.png";
    $backgroundWidth = 600;
    $backgroundHeight = 0;
    $startYPosition=0;
    $padding=0;
    $lines=array();
    $backgroundColor='transparent';
	$elements = "v/uploads/text/name.png";
 $saveImage  ="0";
 
 
 
 
 
         $lines=array();
        $wordSizeArray=array();
        $arrWords=explode(" ", $text);        
        foreach($arrWords as $word){
            $wordSize=imagettfbbox($fontSize, $angle, $fontZ, $word. " ");
            $wordWidth=abs($wordSize[0])+abs($wordSize[2]);
            $wordSizeArray[]=array('word'=>$word, 'size'=>$wordWidth);
        }
        
        $line='';
        $lineWidth=0;
        foreach($wordSizeArray as $wordDetail){
            $word=$wordDetail['word'];
            $wordWidth=$wordDetail['size'];
            $lineWidth+=$wordWidth;
            if($lineWidth<$backgroundWidth-($padding*2)){
                $line.= ' ' . $word;
            }else{
                $line.= "\n" . $word;
                $lineWidth=$wordWidth;
            }
        }
        
         

         $lines = explode("\n",$line);       
        
        if($lineHeight == 0){
            if($underline){
                $lineHeight = $fontSize + ($fontSize*80/100);
            }else{
                $lineHeight = $fontSize + ($fontSize*60/100);
            }
        }
        
        $startYPosition = $fontSize+1;
        
        list($fontColorRed, $fontColorBlue, $fontColorGreen) = hex2rgb($fontColor);
        if($backgroundHeight==0){
            $backgroundHeight = $lineHeight * count($lines) + ($padding*2);
        }

        $background = imagecreatetruecolor($backgroundWidth, $backgroundHeight);        
        
        imagesavealpha($background, true);
        $font_color = imagecolorallocate($background, $fontColorRed, $fontColorBlue, $fontColorGreen);
                
        if($backgroundColor == 'transparent'){
            $bgcolor = imagecolorallocatealpha($background, 0, 0, 0, 127);
        }else{
            list($bgColorRed, $bgColorBlue, $bgColorGreen) = $hex2rgb($backgroundColor);
            $bgcolor = imagecolorallocate($background, $bgColorRed, $bgColorBlue, $bgColorGreen);
        }
        
        imagefill($background, 0, 0, $bgcolor);

                $lineNumber=1;
        foreach($lines as $line){   
            
            $line=trim($line);
            list($xBLeft, $yBLeft, $xBRight, $yBRight, $xTRight, $yTRight, $xTLeft, $yTLeft) = imagettfbbox($fontSize, $angle, $fontZ, $line);
            $lineWidth = abs($xBLeft) + abs($xBRight);
            
            
			
			
			
			        switch ($align) {
            case 'left':
                $startXPosition = abs($xBottomLeft) + $padding;
                break;
            case 'right':
                $startXPosition = $backgroundWidth - $lineWidth - 1 - $padding;
                break;
            case 'center':
                $startXPosition = ($backgroundWidth - $lineWidth) / 2;
                break;
            default:
                $startXPosition = abs($xBottomLeft);
                break;
        }
        
    
            if($lineNumber==1 && $padding>0){
                $startYPosition+=$padding;
            }
            
            imagettftext($background, $fontSize, $angle, $startXPosition, $startYPosition, $font_color, $fontZ, $line);
            if(strlen($line)>0){
                 underline($startXPosition, $lineWidth);
            }
            $startYPosition+=$lineHeight;
            $lineNumber++;
        }
	
		 if($saveImage =="1") 
		 {
			 imagepng($background,"v/uploads/text/".$_GET["pichaNi"].".png");
       		 imagedestroy($background);
			 exit();
		}
		else
		{
        header("content-type: image/png");
        imagepng($background);
       	imagedestroy($background);
		}
         
   
	
	
	
	
  
    
    function underline($startXPosition, $lineWidth){
        if ($underline) {
            $underlineY=$startYPosition+5;
            imagesetthickness($background, 2);
            imageline($background, $startXPosition, $underlineY, $startXPosition+$lineWidth, $underlineY, $font_color);
        }
    }

    function hex2rgb($hex) {
        $hex = str_replace("#", "", $hex);

        if (strlen($hex) == 3) {
            $r = hexdec(substr($hex, 0, 1) . substr($hex, 0, 1));
            $g = hexdec(substr($hex, 1, 1) . substr($hex, 1, 1));
            $b = hexdec(substr($hex, 2, 1) . substr($hex, 2, 1));
        } else {
            $r = hexdec(substr($hex, 0, 2));
            $g = hexdec(substr($hex, 2, 2));
            $b = hexdec(substr($hex, 4, 2));
        }
        $rgb = array($r, $g, $b);
        
        return $rgb;
    }
    
    function pr($str){
        echo "<pre>";
        print_r($str);
        echo "</pre>";
    }