Author Topic: Text2Image intigrated in 4images!?  (Read 5665 times)

0 Members and 1 Guest are viewing this topic.

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.806
  • I ♥ 4I
    • View Profile
Text2Image intigrated in 4images!?
« on: October 10, 2008, 06:24:22 PM »
 :flag-en:
   Hello,

I have found a script with the text as images you can play. I've now tried it with 4images link, but that does not unfortunately not.

First of all what I have done:

1) I have created a new field, as I for other fields also do!
2) I have the box in the member_uploadform.html written:
Code: [Select]
<input type="text" name="image_nfo" size="30" value="{image_nfo}" class="input" /> [/ code]
3) Have Details.html in the field tested with image_nfo (). It went very well.
4) I then tried to use the script, which looks like:

Text2image.php
[code]<?php
define
'FONT_DIR''./' );
include( 
'./image_functions.php' );

$text "This is some sample text made by the script.

 It pains me when I read product feed users, particularly those using php, complain about the duplicate content issue you get when you republish a feed on your site. Its an easy problem to solve with a little programming know how.

One solution I use for this is to present most of the text as an image. If you didn.t know php can dynamically create images using the now standard GD library."
;

$req_height 1;
$width 400;

$text preg_replace'/\n/'' '$text ) ;
// grab font
$font FONT_DIR '/Vera.ttf';


// black and white here

$image imagecreate$width$req_height );
$bg_color ImageColorAllocate$image,  255255255 );
$color ImageColorAllocate$image,  00);

$textSize 10;
$angle 0;
$top 10;
$left 0;
$right $width;
// ImageTTFText( $image, $size, $angle, $top, $left, $text_color, $font , $description );

$height imageprintWordWrapped(&$image$top$left$right$font$color$text$textSize$halign="left") ;

if( 
$height $req_height )
{
ImageDestroy$image );
$image imagecreate$width, ( $height + ( 50 ) ));
$bg_color ImageColorAllocate$image,  255255255 );
$color ImageColorAllocate$image,  00);
imageprintWordWrapped(&$image$top$left$right$font$color$text$textSize$halign="left") ;

}



header'Content-type: image/png' );
ImagePNG$image );





?>


image_functions.php
Code: [Select]
<?php

//
// ripped this from  http://us2.php.net/manual/en/function.imagettfbbox.php
// 

function imageprintWordWrapped(&$image$top$left$right$font$color$text$textSize$halign="left"
{
$maxWidth $right $left ;    //the trivial change
$words explode(' 'strip_tags($text)); // split the text into an array of single words
$line '';
while (count($words) > 0) {
       
$dimensions imagettfbbox($textSize0$font$line.' '.$words[0]);
       
$lineWidth $dimensions[2] - $dimensions[0]; // get the length of this line, if the word is to be included
       
if ($lineWidth $maxWidth) { // if this makes the text wider that anticipated
        
    $lines[] = $line// add the line to the others
        
    $line ''// empty it (the word will be added outside the loop)
       
}
       
$line .= ' '.$words[0]; // add the word to the current sentence
       
$words array_slice($words1); // remove the word from the array
   
}
   
if ($line != '') { $lines[] = $line; } // add the last line to the others, if it isn't empty

// aded some paddding in th eling height
   
$lineHeight 1.5 * ( $dimensions[1] - $dimensions[7] ); // the height of a single line

   
$height count($lines) * $lineHeight// the height of all the lines total
   
// do the actual printing
   
$i 1;
   
//print_R($widths);
   
foreach ($lines as $line) {
   
     if($halign=="center") {
           
//figure out width of line
           
$dimensions imagettfbbox($textSize0$font$line);
           
$lineWidth $dimensions[2] - $dimensions[0];
           
//figure out where the center is.
           
$center=floor($maxWidth/$left);
           
$leftStart=$center-$lineWidth/2;
       
} else if ($halign=="right") {
           
//figure out width of line
           
$dimensions imagettfbbox($textSize0$font$line);
           
$lineWidth $dimensions[2] - $dimensions[0];
           
$leftStart=$left+$maxWidth-$lineWidth;
       
} else {
           
$leftStart=$left;
       

       
imagettftext($image$textSize0$leftStart$top $lineHeight $i$color$font$line);
       
$i++;
   }
   return 
$height;
}









?>


   The script alone, works wonderfully.

   I have in the Details.html instead of image_nfo (), the entire code from the purely Text2image.php packed and
Code: [Select]
$text = "This is some sample text made by the script.

 It pains me when I read product feed users, particularly those using php, complain about the duplicate content issue you get when you republish a feed on your site. Its an easy problem to solve with a little programming know how.

One solution I use for this is to present most of the text as an image. If you didn.t know php can dynamically create images using the now standard GD library.";

be replaced with:
Code: [Select]
$text = "$lang_image_nfo";
That does not work, he shows me only a white page to a picture and wants to spend. But if it is then in the Details.html spent. What should I do? Include it with the same problem. I also have the paths correctly adjusted. What I think is it:
Code: [Select]
header( 'Content-type: image/png' ); lies. Therefore, I wanted to ask you times!

DEMO: http://phisker-produkt.de/text2image.php

:flag-de:
Hallo,

ich habe ein Script gefunden mit dem man Texte als Bilder wiedergeben kann. Ich habe nun versucht es mit 4images zu verknüpfen, aber das geht leider nicht nicht.

Erst einmal was ich gemacht habe:

1) Ich habe ein neues Feld angelegt, so wie ich das für andere Felder auch mache!
2) Ich habe das Feld in die member_uploadform.html geschrieben:
Code: [Select]
<input type="text" name="image_nfo" size="30" value="{image_nfo}" class="input" />3) Habe in der Details.html das Feld getestet mit {image_nfo}. Das klappte sehr gut.
4) Ich habe dann versucht das Script zu verwenden, welches so aussieht:

Text2image.php
Code: [Select]
<?php
define
'FONT_DIR''./' );
include( 
'./image_functions.php' );

$text "This is some sample text made by the script.

 It pains me when I read product feed users, particularly those using php, complain about the duplicate content issue you get when you republish a feed on your site. Its an easy problem to solve with a little programming know how.

One solution I use for this is to present most of the text as an image. If you didn.t know php can dynamically create images using the now standard GD library."
;

$req_height 1;
$width 400;

$text preg_replace'/\n/'' '$text ) ;
// grab font
$font FONT_DIR '/Vera.ttf';


// black and white here

$image imagecreate$width$req_height );
$bg_color ImageColorAllocate$image,  255255255 );
$color ImageColorAllocate$image,  00);

$textSize 10;
$angle 0;
$top 10;
$left 0;
$right $width;
// ImageTTFText( $image, $size, $angle, $top, $left, $text_color, $font , $description );

$height imageprintWordWrapped(&$image$top$left$right$font$color$text$textSize$halign="left") ;

if( 
$height $req_height )
{
ImageDestroy$image );
$image imagecreate$width, ( $height + ( 50 ) ));
$bg_color ImageColorAllocate$image,  255255255 );
$color ImageColorAllocate$image,  00);
imageprintWordWrapped(&$image$top$left$right$font$color$text$textSize$halign="left") ;

}



header'Content-type: image/png' );
ImagePNG$image );





?>


image_functions.php
Code: [Select]
<?php

//
// ripped this from  http://us2.php.net/manual/en/function.imagettfbbox.php
// 

function imageprintWordWrapped(&$image$top$left$right$font$color$text$textSize$halign="left"
{
$maxWidth $right $left ;    //the trivial change
$words explode(' 'strip_tags($text)); // split the text into an array of single words
$line '';
while (count($words) > 0) {
       
$dimensions imagettfbbox($textSize0$font$line.' '.$words[0]);
       
$lineWidth $dimensions[2] - $dimensions[0]; // get the length of this line, if the word is to be included
       
if ($lineWidth $maxWidth) { // if this makes the text wider that anticipated
        
    $lines[] = $line// add the line to the others
        
    $line ''// empty it (the word will be added outside the loop)
       
}
       
$line .= ' '.$words[0]; // add the word to the current sentence
       
$words array_slice($words1); // remove the word from the array
   
}
   
if ($line != '') { $lines[] = $line; } // add the last line to the others, if it isn't empty

// aded some paddding in th eling height
   
$lineHeight 1.5 * ( $dimensions[1] - $dimensions[7] ); // the height of a single line

   
$height count($lines) * $lineHeight// the height of all the lines total
   
// do the actual printing
   
$i 1;
   
//print_R($widths);
   
foreach ($lines as $line) {
   
     if($halign=="center") {
           
//figure out width of line
           
$dimensions imagettfbbox($textSize0$font$line);
           
$lineWidth $dimensions[2] - $dimensions[0];
           
//figure out where the center is.
           
$center=floor($maxWidth/$left);
           
$leftStart=$center-$lineWidth/2;
       
} else if ($halign=="right") {
           
//figure out width of line
           
$dimensions imagettfbbox($textSize0$font$line);
           
$lineWidth $dimensions[2] - $dimensions[0];
           
$leftStart=$left+$maxWidth-$lineWidth;
       
} else {
           
$leftStart=$left;
       

       
imagettftext($image$textSize0$leftStart$top $lineHeight $i$color$font$line);
       
$i++;
   }
   return 
$height;
}









?>


Das Script alleine, klappt wunderbar.

Ich habe in der Details.html an Stelle von {image_nfo}, den gesamten Code aus der Text2image.php reingepackt und
Code: [Select]
$text = "This is some sample text made by the script.

 It pains me when I read product feed users, particularly those using php, complain about the duplicate content issue you get when you republish a feed on your site. Its an easy problem to solve with a little programming know how.

One solution I use for this is to present most of the text as an image. If you didn.t know php can dynamically create images using the now standard GD library.";

mit das ersetzt:
Code: [Select]
$text = "$lang_image_nfo";
Das klappt nicht, er zeigt mir nur eine Weiße Seite an und will ein Bild ausgeben. Es soll aber wenn dann in der Details.html ausgegeben werden. Wie mache ich das? Mit include ist es das gleiche Problem. Ich habe auch die Pfade richtig angepasst. Was ich glaubem, ist das es an:
Code: [Select]
header( 'Content-type: image/png' ); liegt. Daher wollte ich euch mal fragen![/code]

Offline KurtW

  • 4images Guru
  • *******
  • Posts: 2.778
    • View Profile
    • Malediven-Bilder ~~Dreams~~
Re: Text2Image intigrated in 4images!?
« Reply #1 on: October 11, 2008, 03:24:21 PM »
Hallo Phisker B,

was willste denn mit der Umwandlung von Text in Image bezwecken.  :roll:

Kurt

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.806
  • I ♥ 4I
    • View Profile
Re: Text2Image intigrated in 4images!?
« Reply #2 on: October 11, 2008, 04:12:36 PM »
Ja das hat sich wohl doch erledigt. Der Sinn dahinter war, dass User diverse Textdateien hochladen konnten mit diversen Anleitungen. Aber dabei ist mir hinterher ja aufgefallen, dass es keinen Sinn macht. Denn man muss ja bestimmte Codestücke für diverse Addons etc. zum einbauen kopieren und wenn dies als Bild ausgegeben wird.. ist das nicht möglich.

Das war halt der Sinn! Hat sich aber "Vorerst" erledigt.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Text2Image intigrated in 4images!?
« Reply #3 on: October 11, 2008, 06:37:48 PM »
what about a link to the site where you found that code?
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.806
  • I ♥ 4I
    • View Profile