Page 2 of 2

Re: Stroke , Outline Errors and Debian Version 7

Posted: 2018-10-24T01:36:20-07:00
by easy_easy
Hello, still trying to make it work.
I've tried to install new package (from /home/test/ ... ) but failed to install, make at the end, i'm in root user :
Image

Re: Stroke , Outline Errors and Debian Version 7

Posted: 2018-12-16T04:24:39-07:00
by easy_easy
Hello , still the same outline error : even now on shared hosting !!
Maybe webmasters of shared hosting have updated imagemagick version...

The result a normal outline 2 month ago ... on shared hosting (what can make such change with php ? )
And now the same result like my dedicated server ....

So to be clear :
- 2 dedicated server DEBIAN 7 -> outline impossible with some fonts (not all 70% error)
- 2 hosting shared -> outline impossible with some fonts (not all 70% error)

I use imagegik for years on 4 hosting .

Can someone of image magick make search and fixe this .. Thanks It's very annoying, i will have to go back to GD library ??
Image

And config on Shared hosting

Image

An my code : i repeat it works with some fonts perfectly but with differents font it creates errors.

Code: Select all

$font='lobster.ttf';
$n0='test.png';
$font_size=70;
$text='outline';
	$stroke_w=4;
	$draw = new ImagickDraw();
	$draw->setFont($font);
	$ft_real_s = $font_size*1.31;	
	$color_text='#000000';
	$color_stoke='#1e90ff';
	$draw->setFontSize($ft_real_s);
	$draw->setStrokeAntialias(true);
	$draw->setTextAntialias(true);
	$draw->setGravity(Imagick::GRAVITY_NORTHWEST);
	$offset_stroke=($stroke_w*2);
	$image_size = new Imagick(); 
	$metrics = $image_size->queryFontMetrics($draw, $text); 
	$width = $metrics['textWidth']+$offset_stroke*2;
	
	
	    $height = $metrics['textHeight']+$offset_stroke*2;
		$draw->setFillColor($color_text);
		$textOnly = new Imagick();
		$textOnly->newImage($width,$height, "transparent");  
		$textOnly->annotateImage($draw, $offset_stroke, $offset_stroke, 0, $text);  
		
		//Create stroke
		$draw->setFillColor($color_stoke); 
		$draw->setStrokeColor($color_stoke);
		$draw->setStrokeWidth($stroke_w);
		$strokeImage = new Imagick();
		$strokeImage->newImage($width,$height, "transparent");
		$strokeImage->annotateImage($draw, $offset_stroke, $offset_stroke, 0, $text);

		//Composite text over stroke
		$strokeImage->compositeImage($textOnly, imagick::COMPOSITE_OVER, 0, 0, Imagick::CHANNEL_ALPHA );
		$strokeImage->trimImage(0);
		
		$strokeImage->writeImage($n0);
	
		$image_url=$n0;
	
	
		$draw->clear();
		$draw->destroy();
		$strokeImage->clear();
		$strokeImage->destroy();
		$textOnly->clear();
		$textOnly->destroy();
		

Image

Re: Stroke , Outline Errors and Debian Version 7

Posted: 2018-12-16T13:27:53-07:00
by fmw42
I do not use Imagick, but in command line with ImageMagick 6.9.10.16 Mac OSX, the following works fine. Note the need to turn off stroke using +stroke after drawing the blue background characters and before drawing the black ones.

Code: Select all

convert -size 251x76 xc:none \
-gravity center \
-font /Library/fonts/lobster.ttf \
-pointsize 70 \
-fill "#1e90ff" \
-stroke "#1e90ff" \
-strokewidth 4 \
-annotate +0+0 "outline" \
+stroke \
-fill black \
-annotate +0+0 "outline" \
outline_stroke4.png
Image

Code: Select all

convert -size 251x76 xc:none \
-gravity center \
-font /Library/fonts/lobster.ttf \
-pointsize 70 \
-fill "#1e90ff" \
-stroke "#1e90ff" \
-strokewidth 8 \
-annotate +0+0 "outline" \
+stroke \
-fill black \
-annotate +0+0 "outline" \
outline_stroke8.png
Image

Re: Stroke , Outline Errors and Debian Version 7

Posted: 2018-12-17T09:31:44-07:00
by easy_easy
Hello, thanks for your answer.
After 2 hours of test !! i've finally understand why ..
With otf it looks good !! with ttf i've always errors with Lobster and others fonts.
Image

So cool !! i will have to change some fonts to otf ;) or is it possible to update something in order to ttf files work like otf ?
A library to update ? do you know the name of the library that work with ttf and imagemagick ?

Re: Stroke , Outline Errors and Debian Version 7

Posted: 2018-12-17T10:05:04-07:00
by fmw42
Perhaps it is your lobster.ttf font. Try from another source. Also be sure you have the latest version of freetype delegate. I was using freetype @2.9.1_0

Re: Stroke , Outline Errors and Debian Version 7

Posted: 2019-04-22T04:41:52-07:00
by easy_easy
Hello, still the same for me.After hour of update and forum reading i can't find a solution to add stroke with Debian Jessie.
I made test with other system on 3 servers and still the same.
When a text is more that 6 characters with a font with ligature or round effect the line is broken.

if someone see in my script something that can change it will be greatly appreciated.

On a macbook on local it works. On a Debian server with packages it always failed !! a library must create a bug somewhere but where ??
My code :

Code: Select all

$font='Lobster.ttf';
$n0='data/toto.png';
$text="blablablabla-is-atest";
$stroke_w=2;
$draw = new ImagickDraw();
$draw->setGravity(Imagick::GRAVITY_NORTHWEST);
$draw->setFont($font);
$draw->setStrokeColor("#000000");  
$draw->setStrokeWidth($stroke_w);
$draw->setFillColor("#ff0000");
$draw->setFontSize(40); 
$image_size = new Imagick(); 
$metrics = $image_size->queryFontMetrics($draw,$text); 
$width = $metrics['textWidth']+($stroke_w*2);
$height = $metrics['textHeight']+($stroke_w*2);
$strokeImage = new Imagick();
$strokeImage->newImage($width,$height,new ImagickPixel('#00000000'));
$strokeImage->annotateImage($draw, 0, 0, 0, $text);
$strokeImage->writeImage($n0);
$draw->clear();
$draw->destroy();
$strokeImage->clear();
$strokeImage->destroy();

$r=rand(0,4000);
echo'Image text = '.$text.' image name = '.$n0.'<br /><br /><img style="border:1px solid #000;" src="'.$n0.'?v='.$r.'" />';

Image