Topic: Support/Comments for WriteWord  (Read 11009 times)

Pages: 1 [2]   Go Down

#21: 30-Apr-2008, 11:25 AM

checco
Posts: 56

Hi
I try to use the snippet but I get this error:

PHP error debug
  Error:    imagettfbbox(): Could not find/open font   
  Error type/ Nr.:    Warning - 2   
  File:    /Library/Apache2/htdocs/demo/manager/includes/document.parser.class.inc.php(769) : eval()'d code   
  Line:    84

This is the snippet call:

[[WriteWord?&file=`media/Ordnerin.ttf` &text=`[*pagetitle*]` &text_size=`26` &text_color=`#333333` &bg_color=`#FFFFFF` &quality=`100` &tpl=`writeword`]]

I have uploaded the font in the media folder.
The GD2 library is installed.
The server is a Mac osx

Any idea. Thank you.

#22: 1-May-2008, 04:21 PM

checco
Posts: 56

Resolved  Smiley
the problem was related to permission.

#23: 28-Jul-2008, 03:49 AM

IG88
Posts: 119

In the read me file it states
Quote
The image will be duplicated with a hidden text that will be a search engine friendly.

This is pretty straight forward, but how good is it? I mean how well will it do with SEO as opposed to using regular web safe font?

#24: 19-Mar-2009, 12:11 PM


FuryDE
Posts: 315

Hi, what a wonderful snippet Smiley It works very good (for me).

I'm wondering if it would be much work to buil a plugin that automatically converts all headlines to images, using this snippet. I have not done any plugin for now, so that's why I'm asking. I only was into snippets so far.

Greetings
Martin

#25: 6-Apr-2009, 04:49 AM


FuryDE
Posts: 315

Ok, I know now that it (plugin) would work, but it is not too good for me to convert all H1 ...

I have a different problem now: Snippet works great, BUT: it does not convert German Umlauts. I want the page title "Möbel" to be converted, but I receive "M bel" with a space instead of ö.

Character encoding of the website is set to UTF-8. The font includes umlauts.

Any idea anybody?
Thanks
Martin

#26: 15-May-2009, 04:55 AM

eerne
Posts: 118

WWW
Hi

I tried to make a version (string2png) with letterspacing and wordspacing but with some fonts it didn't look nicely. http://modxcms.com/forums/index.php/topic,30640.new/topicseen.html

String2png can also do real alpha transparency. Now I ported this alpha-transparency-feature back to WriteWord. Hope it works for you and you like it  Smiley

Here is the code.



Code:
<?php
//////////////////////////////////////////////////////////////////////////////////////////////////
//
// Snippet Name:  WriteWord
// Short Description: This snippet allows to generate image from the text with any font
// Version:  0.25 ALPHA
// Author:  Metaller
// Translator: Igor
// 
//////////////////////////////////////////////////////////////////////////////////////////////////

if (!isset($file)) return "Font file is not entered!";
(isset(
$text)) ? $text $text "Text string is empty!";
(isset(
$text_angle)) ? $text_angle $text_angle 0;
(isset(
$text_size)) ? $text_size $text_size 14;
(isset(
$text_color)) ? $text_color $text_color "#000000";
(isset(
$bg_color)) ? $bg_color $bg_color "#FFFFFF";
$scale = ($scale == TRUE) ? TRUE FALSE;
$format strtolower($format);
$format = ($format == "png") ? "png" "jpg";
$transparent = ($transparent == TRUE) ? TRUE FALSE;
(isset(
$quality)) ? $quality $quality 70;

$ww_template $tpl $modx->getChunk($tpl):  "<img src='[+ww.fileurl+]' width='[+ww.width+]' height='[+ww.height+]' border='0' title='[+ww.text+]'>";

if (
substr($text_color0,1) == "#"$text_color substr($text_color1,6);
if (
substr($bg_color0,1) == "#"$bg_color substr($bg_color1,6);

$result compact("file",  "text",  "text_angle",  "text_size",  "text_color",  "bg_color""scale",  "format",  "transparent""quality");

foreach (
$result as $k=>$v)
{
$res[] = $k."=".$v;
}

$qry implode("&"$res);

$code md5($qry);

$filename=$modx->config['base_path']."assets/cache/{$code}.pageCache.{$format}";
$fileurl $modx->config['base_url']."assets/cache/{$code}.pageCache.{$format}";

if (
file_exists($filename)) 
{
$size getimagesize($filename);
$im_width $size[0];
$im_height $size[1];

$ww_template str_replace('[+ww.width+]'$im_width$ww_template);
$ww_template str_replace('[+ww.height+]'$im_height$ww_template);
$ww_template str_replace('[+ww.fileurl+]'$fileurl$ww_template);
$ww_template str_replace('[+ww.text+]'$text$ww_template);

return $ww_template;
}


if (
$modx->config['modx_charset']!="UTF-8"$text mb_convert_encoding($text"UTF-8"$modx->config['modx_charset']);

if (!
extension_loaded('gd')) {
if (strtoupper(substr(PHP_OS0,3) == 'WIN')) {
@dl('php_gd2.dll');
}
else {
@dl('gd2.so');
}
}

$fontstmp$modx->config['base_path']."assets/".$file;

$text_font sprintf("%s",$fontstmp);

$box  imagettfbbox $text_size$text_angle$text_font$text);
$text_width $box[2]-$box[0];
$text_height$box[5]-$box[3];


if (
$scale)
{
$text_size  round((20 $im_width)/$text_width);
$box  imagettfbbox $text_size$text_angle$text_font$text);
$text_width $box[2]-$box[0];
$text_height$box[5]-$box[3];

$text_x      = ($im_width $text_width)/2;
$text_y  = ($im_height $text_height)/2;
}else{
$im_width = (isset($im_width))  ? $im_width abs($text_width);
$im_height = (isset($im_height))  ? $im_height abs($text_height);
$text_x      = -$box[6]-1;
$text_y  = -$box[7]-1;
}
if(
$transparent){
$im_text  imageCreateTrueColor ($im_width$im_height);
imageSaveAlpha($im_texttrue);
imageAlphaBlending($im_textfalse);
$tlo imagecolorallocatealpha($im_text220220220127);
imagefill($im_text00$tlo);
}else{
$im_text  imagecreate ($im_width$im_height);
}

$bg_r hexdec(substr($bg_color0,2));
$bg_g hexdec(substr($bg_color2,2));
$bg_b hexdec(substr($bg_color4,2));

$bgcolor  imagecolorallocate ($im_text$bg_r$bg_g$bg_b);

$text_r hexdec(substr($text_color0,2));
$text_g hexdec(substr($text_color2,2));
$text_b hexdec(substr($text_color4,2));

$textcolor  imagecolorallocate ($im_text$text_r$text_g$text_b);

imagettftext ( $im_text,
$text_size,
$text_angle,
$text_x,
$text_y,
$textcolor,
$text_font,
$text);

if (
$transparentimagecolortransparent($im_text$bgcolor);

if (
$format == "png")
{
if (!file_exists($modx->config['base_path']."assets/cache/{$code}.pageCache.{$format}")) imagepng($im_text$modx->config['base_path']."assets/cache/{$code}.pageCache.{$format}"); 
}
else
{
if (!file_exists($modx->config['base_path']."assets/cache/{$code}.pageCache.{$format}")) imagejpeg($im_text$modx->config['base_path']."assets/cache/{$code}.pageCache.{$format}",$quality); 
}

imagedestroy($im_text);

if (
$modx->config['modx_charset']!="UTF-8"$text mb_convert_encoding($text$modx->config['modx_charset'], "UTF-8");


$ww_template str_replace('[+ww.width+]'$im_width$ww_template);
$ww_template str_replace('[+ww.height+]'$im_height$ww_template);
$ww_template str_replace('[+ww.fileurl+]'$fileurl$ww_template);
$ww_template str_replace('[+ww.text+]'$text$ww_template);

return 
$ww_template;
?>

#27: 15-May-2009, 05:02 AM

eerne
Posts: 118

WWW
Could somebody give me a working example of the scale option? I get some parser error Sad

Code:
[[WriteWord? &file=`media/somefont.ttf` &text=`foo`&scale=`TRUE`]]

Code:
PHP error debug
  Error: imagecreate() [function.imagecreate]: Invalid image dimensions
  Error type/ Nr.: Warning - 2
  File: /home/httpd/vhosts/mydomain.ch/subdomains/modxcms/httpdocs/manager/includes/document.parser.class.inc.php(772) : eval()'d code
  Line: 100

#28: 15-May-2009, 05:15 AM


elz64
Posts: 427

WWW
Hi,

Thank you for your nice snippet.

Works fine, but:

The way you suggest to outputs the image in snippet comments (tpl part)  is not so good, regarding an accessibility point of view

the default tpl coded into the snippet looks far better, except I suggest using the alt tag into the img (otherwise it's not valid neither),
This is more useful than the title, because if images are disabled or text reading device read the text it'll never find any text to read (afaik)
(title tag is quit unuseful in case of page title)

But I'm very confused by the tpl chunck for this output

if I use this into my tpl chunk
Code:
<img src="([+ww.fileurl+])"  width="[+ww.width+]" height="[+ww.height+]" alt="titre page:[+ww.text+]" title="[+ww.text+]" />
Nothing works  Huh

If I copy the harcoded one and adapt it using simple quote instead of double ", like this:
Code:
<img src='[+ww.fileurl+]' width='[+ww.width+]' height='[+ww.height+]' border='0' title='[+ww.text+]' />

It works  Undecided

So I just discovered img tag can be use with simple quote inside...

 is this code is normal ?

Thank you

Schtroumpf Grognon - Grouchy Smurf
---------------------------------
Faites pas attention.. - Don't pay attention

#29: 17-May-2009, 09:22 PM

adhiarta
Posts: 26

Could somebody give me a working example of the scale option? I get some parser error Sad

Code:
[[WriteWord? &file=`media/somefont.ttf` &text=`foo`&scale=`TRUE`]]

Code:
PHP error debug
  Error: imagecreate() [function.imagecreate]: Invalid image dimensions
  Error type/ Nr.: Warning - 2
  File: /home/httpd/vhosts/mydomain.ch/subdomains/modxcms/httpdocs/manager/includes/document.parser.class.inc.php(772) : eval()'d code
  Line: 100

I have the same problem

#30: 18-May-2009, 09:51 AM


elz64
Posts: 427

WWW

Hi adhiarta,


I dont tried the scale option but, may be you must use the
Code:
width='[+ww.width+]' height='[+ww.height+]'
in your template isn't it ?



Schtroumpf Grognon - Grouchy Smurf
---------------------------------
Faites pas attention.. - Don't pay attention

#31: 18-May-2009, 10:00 AM


Metaller
Posts: 1,207

Hello. I wrote this plugin many time ago and now i think that it's not realy good. May be some time later I'll try to totally rewrite it with todays expirience. But now you can use it "as is".
DirectResize 0.9 beta. PHPThumb, sets of configurations, configuration, binded to specific path. No backward compatibility. | DirectResize 0.9. PHPThumb, наборы параметров, параметры, привязанные к определенным путям. Без обратной совместимости.

Unfortunately, DirectResize project is closed. If you want to continue development, PM me for access to project page on Google Code. К сожалению, проект DirectResize закрыт. Если вы желаете продолжить разработки, обращайтесь через ПМ для получения доступа к репозиторию на Google Code.

[PLUGIN] DirectResize - as Maxigallery but for single images :: Download :: Support :: Old topic
Maxigallery для одиночных изображений - русскоязычный топик

#32: 22-Aug-2009, 03:57 PM


andrew4u
Posts: 29

Hello. I wrote this plugin many time ago and now i think that it's not realy good. May be some time later I'll try to totally rewrite it with todays expirience. But now you can use it "as is".

Sounds great.. thanks for your work and looking forward to you new code!
MODx is way ahead... Thanks for your work!

#33: 12-Feb-2010, 12:31 PM

Austinkir
Posts: 2

Thanks for this great script! I would be very interested in a future version. I would love to see how this code would be made better as I think it would help me learn this kind of thing, as well.

Thanks again!

#34: 13-Feb-2010, 12:27 AM


Metaller
Posts: 1,207

Sorry,

unfortunately, I left the development of snippets for MODx. May be someone else will continue this work.

Good luck!
DirectResize 0.9 beta. PHPThumb, sets of configurations, configuration, binded to specific path. No backward compatibility. | DirectResize 0.9. PHPThumb, наборы параметров, параметры, привязанные к определенным путям. Без обратной совместимости.

Unfortunately, DirectResize project is closed. If you want to continue development, PM me for access to project page on Google Code. К сожалению, проект DirectResize закрыт. Если вы желаете продолжить разработки, обращайтесь через ПМ для получения доступа к репозиторию на Google Code.

[PLUGIN] DirectResize - as Maxigallery but for single images :: Download :: Support :: Old topic
Maxigallery для одиночных изображений - русскоязычный топик

#35: 13-Feb-2010, 08:40 AM


charliez
Posts: 554

WWW
I think that Cufon (a javascript text to image transformer)
does similar stuff like this.  It is lightweight, super fast
and allow you to use multiple fonts on multiple elements (h2, h4, p, etc)...
Website: www.mercologia.com 
Blog (in Español): Digital Stickiness www.mercologia.com/blog
Pages: 1 [2]   Go Up
0 Members and 1 Guest are viewing this topic.