To Create A Generator Of Images Based On Avatar Generator
| Article |
 To Create A Generator Of Images Based On Avatar Generator
|
Hello to all, I would have need of knowing some things.
I am trying to create a generator of sign basing to me on the code of: " Avatar Generator"
I must simply replace the images with those which I will use like base in order to create the companies.
The page will have to be raggiungibile directly gives /sign_generator.php.
I am using this code:
<?php
/**
*
* @package: Icy Phoenix
* @version $Id: generate_sign.php - 1.0.0 - 2006/09/29
* @copyright (c) 2006 Mighty Gorgon
* @license http://opensource.org/licenses/GPL-license.php GNU Public License
*
*/
// CTracker_Ignore: File checked by human
define('IN_PHPBB', true);
define('MG_CTRACK_FLAG', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.' . $phpEx);
$fonts_path = 'images/fonts/';
$generator_template_path = 'images/sign/base/';
$dest_pic = htmlspecialchars($_GET['cachefile']);
$source_pic = htmlspecialchars($_GET['signfile']);
$source_pic_full = $source_pic . '.png';
$text_content = htmlspecialchars(stripslashes($_GET['text_content']));
$text_size = (isset($_GET['text_size'])) ? intval($_GET['text_size']) : '10';
//$text_font = (isset($_GET['text_font'])) ? htmlspecialchars($_GET['text_font']) : 'triplex_bold.ttf';
$text_font = (isset($_GET['text_font'])) ? htmlspecialchars($_GET['text_font']) : 'tahoma.ttf';
$text_font = $fonts_path . $text_font;
$text_color = (isset($_GET['text_color'])) ? htmlspecialchars($_GET['text_color']) : '#FFFFFF';
$text_position = (isset($_GET['text_position'])) ? htmlspecialchars($_GET['text_position']) : '0';
$sign_array = array('background_1', 'background_2');
if (in_array($source_pic_full, $sign_array))
{
$source_pic = $generator_template_path . $source_pic_full;
}
else
{
$num = mt_rand(1, count($sign_array));
$source_pic = $generator_template_path . $sign_array[$num];
}
write_text($source_pic, $dest_pic, $text_content, $text_font, $text_size, $text_color, $text_position);
//write_text($source_pic, $dest_pic, $text_content, $text_font, $text_size, '#FFFFAA', $text_position);
/**
* Write text on images
*
* Detail description
* @param none
* @since 1.0
*/
function write_text($source_pic, $dest_pic, $text_content, $text_font, $text_size = '10', $text_color = '#FFFFFF', $text_position = '0')
{
$temp_pic = imagecreatefrompng($source_pic);
list($image_width, $image_height) = getimagesize($source_pic);
/*
$temp_pic_empty = imagecreatetruecolor ($image_width, $image_height);
imagealphablending($temp_pic_empty, false);
imagecopyresampled($temp_pic_empty, $temp_pic, 0, 0, 0, 0, $image_width, $image_height, $image_width, $image_height);
imagesavealpha($temp_pic_empty, true);
//imagepng($im_re, 'small_redfade.png');
$temp_pic2 = imagecreatefrompng($source_pic);
*/
// Calculate the centre
for(;;)
{
list($left_x, , $right_x) = imagettfbbox($text_size, $text_position, $text_font, $text_content);
$text_width = $right_x - $left_x;
if($image_width > $text_width + 5)
{
break;
}
$text_size = $text_size - 0.5;
if($text_size == 1)
{
die('Font size may not be reduced further, try to insert a shorter text');
}
}
$text_padding = ($image_width - $text_width) / 2;
$text_color = (substr($text_color, 0, 1) == '#') ? substr($text_color, 1, 6) : $text_color;
$text_color_r = hexdec(substr($text_color, 0, 2));
$text_color_g = hexdec(substr($text_color, 2, 2));
$text_color_b = hexdec(substr($text_color, 4, 2));
$text_color = imagecolorresolve($temp_pic, $text_color_r, $text_color_g, $text_color_b);
//$text_color = imagecolorallocate($temp_pic, $text_color_r, $text_color_g, $text_color_b);
imagettftext($temp_pic, $text_size, $text_position, $text_padding, ($image_height - ($text_size / 2)), $text_color, $text_font, $text_content);
if($_GET['dl'])
{
header('Content-Disposition: attachment; filename="sign.png"');
}
header("Content-type: image/png");
imagepng($temp_pic, $dest_pic);
imagepng($temp_pic);
imagedestroy($temp_pic);
/*
header('Content-type: image/gif');
imagegif($temp_pic, $dest_pic);
imagegif($temp_pic);
imagedestroy($temp_pic);
*/
return true;
}
?>
but when I go to visit the page gives back to me:
Warning: imagecreatefrompng() [function.imagecreatefrompng]: 'images/sign/base/' is not a valid PNG file in /web/htdocs/www.makingart.org/home/sign_generator.php on line 56
Warning: getimagesize() [function.getimagesize]: Read error! in /web/htdocs/www.makingart.org/home/sign_generator.php on line 57
Font size may not be reduced further, try to insert a shorter text
or
Warning: imagecreatefrompng(images/sign/base/background_2) [function.imagecreatefrompng]: failed to open stream: No such file or directory in /web/htdocs/www.makingart.org/home/sign_generator.php on line 56
Warning: getimagesize(images/sign/base/background_2) [function.getimagesize]: failed to open stream: No such file or directory in /web/htdocs/www.makingart.org/home/sign_generator.php on line 57
Font size may not be reduced further, try to insert a shorter text
instead in the folder two rows are present these:
- background_1.png
- background_2.png
You can help at least giving a input me in order to finish this modification to me that in my situated one serves enough?
I say thanks in advance payment all 
|
|
FedericoBiccheddu [ Thu 26 Jun, 2008 13:40 ]
|
 |
Sponsors

|
Icy Phoenix is an open source project, you can show your appreciation and support future development by donating to the project.
|
 |
To Create A Generator Of Images Based On Avatar Generator
| Comments |
 Re: To Create A Generator Of Images Based On Avatar Generato
|
|
Are you sure you have edited the TPL as well?
Did you edit it properly?
|
|
Mighty Gorgon [ Thu 26 Jun, 2008 17:03 ]
|
 |
 Re: To Create A Generator Of Images Based On Avatar Generato
|
Are you sure you have edited the TPL as well?
Did you edit it properly?
Excused for the section
In the file .php I do not know where to specify which .tpl to make reference. In Avatar Generator the same one, it does not come specified
EDIT: Now watching IP.com me they are shrewed that you have nearly to 100% the one which serves to me, that is, CustomIcy Banners. To me it serves a thing of the sort without the possibility of chosen of the color and movement of the text...
You will not believe to us but for my site it is absolutely essential 
|
|
FedericoBiccheddu [ Thu 26 Jun, 2008 17:58 ]
|
 |
 Re: To Create A Generator Of Images Based On Avatar Generato
|
I'm sure you didn't edit the TPL properly...
Check this file: templates/mg_themes/profile_avatar_generator.tpl
Especially this part...
<img src="generate_avatar.php?cachefile={AVATAR_FILENAME}&avatarfile={S_IMAGE_NAME}&text_content={S_IMAGE_TEXT}" alt="{L_YOUR_AVATAR}" />
|
|
Mighty Gorgon [ Wed 02 Jul, 2008 12:55 ]
|
 |
|
|
Was this topic useful?
Was this topic useful?
|
Page 1 of 1
|
|
|