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:
<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, 255, 255, 255 );
$color = ImageColorAllocate( $image, 0, 0, 0 );
$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, 255, 255, 255 );
$color = ImageColorAllocate( $image, 0, 0, 0 );
imageprintWordWrapped(&$image, $top, $left, $right, $font, $color, $text, $textSize, $halign="left") ;
}
header( 'Content-type: image/png' );
ImagePNG( $image );
?>
image_functions.php
<?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($textSize, 0, $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($words, 1); // 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($textSize, 0, $font, $line);
$lineWidth = $dimensions[2] - $dimensions[0];
//figure out where the center is.
$center=floor($maxWidth/2 + $left);
$leftStart=$center-$lineWidth/2;
} else if ($halign=="right") {
//figure out width of line
$dimensions = imagettfbbox($textSize, 0, $font, $line);
$lineWidth = $dimensions[2] - $dimensions[0];
$leftStart=$left+$maxWidth-$lineWidth;
} else {
$leftStart=$left;
}
imagettftext($image, $textSize, 0, $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
$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:
$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:
header( 'Content-type: image/png' );
lies. Therefore, I wanted to ask you times!
DEMO: http://phisker-produkt.de/text2image.php
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:
<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
<?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, 255, 255, 255 );
$color = ImageColorAllocate( $image, 0, 0, 0 );
$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, 255, 255, 255 );
$color = ImageColorAllocate( $image, 0, 0, 0 );
imageprintWordWrapped(&$image, $top, $left, $right, $font, $color, $text, $textSize, $halign="left") ;
}
header( 'Content-type: image/png' );
ImagePNG( $image );
?>
image_functions.php
<?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($textSize, 0, $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($words, 1); // 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($textSize, 0, $font, $line);
$lineWidth = $dimensions[2] - $dimensions[0];
//figure out where the center is.
$center=floor($maxWidth/2 + $left);
$leftStart=$center-$lineWidth/2;
} else if ($halign=="right") {
//figure out width of line
$dimensions = imagettfbbox($textSize, 0, $font, $line);
$lineWidth = $dimensions[2] - $dimensions[0];
$leftStart=$left+$maxWidth-$lineWidth;
} else {
$leftStart=$left;
}
imagettftext($image, $textSize, 0, $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
$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:
$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:
header( 'Content-type: image/png' );
liegt. Daher wollte ich euch mal fragen![/code]