Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
GD Question WARNING: ADVANCED
Old 11-29-2007, 11:06 PM GD Question WARNING: ADVANCED
Mattmaul1992's Avatar
Ultra Talker

Posts: 486
Name: Matt
Trades: -1
You know when you write a script and have no idea why it's not working? Well, this usually doesn't happen because the PHP god gave us error messages. If you're doing something like this in which you may not get in error message for many errors you might make it's hard, and sometimes impossible to find out what went wrong. So I want to know if you guys see any reason this script shouldn't work.
Just to explain what I want it to do - The script has an array with a character in every key (Mattmaul1992). There's a foreach loop in which the individual replacement character widths are found and the individual replacement characters source is found. After I have the final string width calculated I create a new string image and merge all the individual character images together into that new string imgae. I then merge the string image onto the background image. Why go through all this trouble? It's the only way to center the string to the pixel. Well it will be after a nice long equation.
GD scripts can get confusing and most people aren't familiar with the library so I can understand if no one can help me out but if you want a challenge here's your chance lol. Thanks.

PHP Code:
<?php
//--------------------------------------------------------------------
// BACKGROUND
// http://www.image2life.net/users/public/f30104bg_imaged182.png
//--------------------------------------------------------------------
// TO DO: Make a file for each skin which includes all the BG/character info
$skin_id 1;
$bg 'http://www.image2life.net/users/public/g22930the_bgu182.png';
$num_1 'http://www.image2life.net/users/public/q23270the_num_1w182.png';
$num_1 imageCreateFromPNG($num_1);
$bg_img imageCreateFromPNG($bg);

// Create and format the username string to be added to the main image...
$username 'Mattmaul1992';
$username_array = array('M''a''t''t''m''a''u''l''1''9''9''2');
$char_image_lib_srcs = array();
$char_widths = array();
$char_widths_current_key 0;
$string_total_width 0;
$counter 0;
foreach (
$username_array as $key => $value)
{
$image_size getImageSize($num_1);
$char_widths[$char_widths_current_key] = $image_size[0];
$string_total_width += $image_size[0];
$char_image_lib_srcs[$counter] = $num_1;
$char_widths_current_key++;
$counter++;
}
$string_img imageCreate($string_total_width14);
foreach(
$char_image_lib_srcs as $key => $value)
{
imageCopyMerge($string_img$num_1$char_widths[$key], 0001014100);
}

imageCopyMerge($bg_img$string_img5000$string_total_width14100);

/*
Funcion I'll use when an image lib is in
foreach ($username_array as $key => $value)
{
$image_size = getImageSize('/image_libs/' . $skin_id . '/characters/' . $value);
$char_widths[$char_widths_current_key] = $image_size[0];
$string_total_width += $image_size[0];
$char_image_lib_srcs[$counter] = ('/image_libs/' . $skin_id . '/characters/' . $value);
$counter++;
}*/

//imageCopyMerge($bg_img, $num_1, 5, 5, 0, 0, 10, 14, 100);
//$textcolor = imagecolorallocate($bg_img, 0, 0, 255);
//imagestring($bg_img, 5, 50, 0, $username, $textcolor);
header("Content-type: image/png");
imagePNG($bg_img);
?>
__________________
PHP Code:
$talkupation++; 

Please login or register to view this content. Registration is FREE
- Free IPB forum hosting (releasing today!!!), no ads, free modifications
Mattmaul1992 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to GD Question WARNING: ADVANCED
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.08118 seconds with 12 queries