Jump to content

[SOLVED] Copyright symbol in imagestring


youknowho

Recommended Posts

I am successfully watermarking images with imagestring, but have yet to get the copyright symbol to appear correctly. I've tried htmlspecialchars_decode:

 

$copyString = htmlspecialchars_decode('©', ENT_QUOTES) . date(Y) . ' My Company';
imagestring($image, 3, 80, 475, $copyString, $black);

 

I've also tried html_entity_decode:

 

$copyString = html_entity_decode("©") . date(Y) . ' My Company';
imagestring($image, 3, 80, 475, $copyString, $black);

 

which according to http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_23295622.html works, but not for me.

 

I also set default_charset = "iso-8859-1" in php.ini on the chance that a different charset was being used for some reason. No matter what I try I get an "A" or "S" with markings above it (which I think are coming from another character set). Ideas?

Link to comment
https://forums.phpfreaks.com/topic/129451-solved-copyright-symbol-in-imagestring/
Share on other sites

Geeze it is a font issue thank you. I assumed imagestring would support the copyright symbol but it doesn't. When I try:

 

imagefttext ($image, 15, 0, 160, 485, $black, '/usr/.../fonts/LucidaSansDemiBold.ttf', chr(169) . date(Y) . ' My Company');

 

it works fine. I was hoping to use imagestring because the freetype text looks really pixelated/muddled (even with png output). I've seen an Imagemagick solution but don't know if it's installed on the host. All I want is a clear copyright notice on my image!

I don't think it's the function... it's more than likely the font you've used IN the function.

 

You're going to have to grab a gdf font that contains the copyright symbol in order to do it.

 

Alternately, use a TTF font!

 

<?php

$im = imagecreate( 80,50 );

$bg = imagecolorallocate( $im, 255, 255, 255 ); 
$txt = imagecolorallocate( $im, 0, 0, 0 ); 

imagettftext( $im, 12, 0, 15, 30, $txt, 'C:/windows/fonts/arial.ttf', chr(169).' 2008' );

header('Content-type: image/png');

imagepng($im);

?>

I can use true type fonts with imagettftext and imagefttext but as I mentioned, the quality is horrible. I made an arial gdf font and it looks equally bad.

 

I did notice in the imagestring documentation that the encoding is latin2, so I'm going to work on changing that for the string printed to the image.

 

Thanks.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.