Urgent - Problem update

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
figou92
Posts: 3
Joined: 2016-09-22T01:58:44-07:00
Authentication code: 1151

Urgent - Problem update

Post by figou92 »

Hello,

We were working with ImageMagick 6.6.0-4 and every thing was great.

We have updated to 6.9 and now arc text is doing bad stuffs.... look at the picture. Anyone could help wuth this issue ?
Attachments
tn_erreur.png
tn_erreur.png (37.27 KiB) Viewed 16029 times
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Urgent - Problem update

Post by snibgo »

This is the IMagick forum? Are you using IMagick?

It may help if you show the code you use to create that image.
snibgo's IM pages: im.snibgo.com
figou92
Posts: 3
Joined: 2016-09-22T01:58:44-07:00
Authentication code: 1151

Re: Urgent - Problem update

Post by figou92 »

function imagettftextarc2($image, $size, $angle, $x, $y, $r, $color, $fontfile, $text, $dir=false, $float_indice = 0.5, $xDebutContainer = 8, $txtMaxWidth = 240){

$tabAfterResize = resizeFont($text, $size, $txtMaxWidth, $fontfile );
$size = $tabAfterResize['font_size'];

//Centrer le texte dans l'arc
// $xDebutContainer = 0;
// echo $tabAfterResize['str_size'].'pi';
if($dir == false){
$zoneX = ceil($xDebutContainer + (($txtMaxWidth - $tabAfterResize['str_size']) / M_PI));
}else
{
$zoneX = ceil($xDebutContainer - (($txtMaxWidth - $tabAfterResize['str_size']) / M_PI) );
}

$sbox = imagettfbbox($size, 0, $fontfile, ' ');
$sbox = ($sbox[2]-$sbox[0])* $float_indice;


$angle = $angle + ($zoneX ) ;
//$angle en radian
// $angle = $angle * M_PI / 180;
$angle = deg2rad($angle);

foreach(preg_split('//u', $text) AS $t){
$px = $x+$r*cos($angle);
$py = $y+$r*sin($angle);

/*
$px = round($x+$r*cos($angle));
$py = round($y+$r*sin($angle));
*/

//Retransformation en degres pour l'affichage
$dirangle = (360-(M_PI/2+$angle)*180/M_PI+($dir?180:0))%360;
$box = imagettfbbox($size, 0, $fontfile, $t);
$dx = ($box[2]-$box[0]);
// echo "angle : ".$dirangle."<br/>";



if($angle < 2.85 && $angle > 1.80 && ($dx >= ($size -5)))
{
$dirangle = $dirangle + 7;
$dx = $dx - 3;

}elseif($angle < 1.45 && $angle > 0.80 && ($dx >= ($size -3))){

$dirangle = $dirangle + 5;


}elseif($angle < 1.77 && $angle > 1.49)
{
$dirangle = $dirangle + 5;
}
//$dirangle = $dirangle + 7;
if($dx >= ($size -1))
{
$dx = $dx -5;
}
$da = abs(asin(($dx+$sbox)/$r));


imagettftext($image, $size, $dirangle, $px , $py, $color, $fontfile, $t);


if($dir){
$angle-=$da;
}else{
$angle+=$da;
}

}
}
figou92
Posts: 3
Joined: 2016-09-22T01:58:44-07:00
Authentication code: 1151

Re: Urgent - Problem update

Post by figou92 »

Code: Select all

function imagettftextarc2($image, $size, $angle, $x, $y, $r, $color, $fontfile, $text, $dir=false, $float_indice = 0.5, $xDebutContainer = 8, $txtMaxWidth = 240){
 
	$tabAfterResize = resizeFont($text, $size, $txtMaxWidth, $fontfile  );
	$size = $tabAfterResize['font_size'];
	
	//Centrer le texte dans l'arc
	// $xDebutContainer = 0;
	// echo $tabAfterResize['str_size'].'pi';
	if($dir == false){
		$zoneX = ceil($xDebutContainer + (($txtMaxWidth - $tabAfterResize['str_size']) / M_PI));
	}else 
	{
		$zoneX =  ceil($xDebutContainer - (($txtMaxWidth - $tabAfterResize['str_size']) / M_PI) );
	}
 
    $sbox = imagettfbbox($size, 0, $fontfile, ' '); 
    $sbox = ($sbox[2]-$sbox[0])* $float_indice;
 
	 
	 $angle  = $angle + ($zoneX ) ;
	//$angle en radian
    // $angle = $angle * M_PI / 180;
    $angle = deg2rad($angle);
 
    foreach(preg_split('//u', $text) AS $t){ 
        $px = $x+$r*cos($angle);
        $py = $y+$r*sin($angle);
 
/* 
		$px = round($x+$r*cos($angle));
        $py = round($y+$r*sin($angle));
*/

		//Retransformation en degres pour l'affichage
        $dirangle = (360-(M_PI/2+$angle)*180/M_PI+($dir?180:0))%360;
	   $box = imagettfbbox($size, 0, $fontfile, $t); 
	   $dx = ($box[2]-$box[0]);
	//   echo "angle : ".$dirangle."<br/>";
  
 
		
	 if($angle < 2.85 && $angle > 1.80 && ($dx >= ($size -5)))
	 {
		$dirangle = $dirangle + 7; 
		 $dx = $dx - 3; 
		
	 }elseif($angle < 1.45 && $angle > 0.80 && ($dx >= ($size -3))){
	 
	 $dirangle = $dirangle + 5;
 
	 
	 }elseif($angle < 1.77 && $angle > 1.49)
	 {
		$dirangle = $dirangle + 5;
	 }
		//$dirangle = $dirangle + 7;
	  if($dx >= ($size -1))
	  {
			$dx = $dx -5;
	  }
		$da = abs(asin(($dx+$sbox)/$r));	
		
		 
        imagettftext($image, $size, $dirangle, $px , $py, $color, $fontfile, $t);
    
      
        if($dir){
            $angle-=$da;
        }else{
            $angle+=$da;
        }
		 
    }
}
Post Reply