Jump to content

[SOLVED] image creation freezes under werid condition


bkswindell

Recommended Posts

Hello, thanks for taking the time to help.  Ive designed a code to create an image that uses user input of 8 or less chars, and converts it to an array and displays the correct image for each char.  So far the code works 95% it creates the image ok execpt for a few conditions. Ok so

 

http://bkswindell.dyndns.org:8091/dev/project/trunk/php/test4.php?strings=12345678  Works

http://bkswindell.dyndns.org:8091/dev/project/trunk/php/test4.php?strings=1  Works

http://bkswindell.dyndns.org:8091/dev/project/trunk/php/test4.php?strings=12  Works

http://bkswindell.dyndns.org:8091/dev/project/trunk/php/test4.php?strings=123  Freezes  ???

http://bkswindell.dyndns.org:8091/dev/project/trunk/php/test4.php?strings=1234  Works

http://bkswindell.dyndns.org:8091/dev/project/trunk/php/test4.php?strings=12345  Works

and the rest works up to 12345678 and the other condition:

 

http://bkswindell.dyndns.org:8091/dev/project/trunk/php/test4.php?strings=%20%20%20%20%20%20%201  Works

http://bkswindell.dyndns.org:8091/dev/project/trunk/php/test4.php?strings=%20%20%20%20%20%2012  Freezes  ???

http://bkswindell.dyndns.org:8091/dev/project/trunk/php/test4.php?strings=%20%20%20%20%20123  Works

And so on to %201.

Im think it has some to do with the math but im not finding and problems.  Any help would be much appricated.  Also feel free to do and testing of other contitions.

 

Brad

 

<?php  

header('content-type: image/jpeg');

$image = imagecreatefromgif('emp.gif');  
$size = getimagesize('emp.gif');  

$strings = $_GET['strings'];

$len = strlen($strings);
$cur = 0;
$characterarray = array();
while($cur < $len){
$char = $strings{$cur};
array_push($characterarray,$char);
$cur = $cur + 1;
}

/* "*---*"  "      --" */

$car1 = imagecreatefromgif($characterarray[0].'.gif');
$car2 = imagecreatefromgif($characterarray[1].'.gif');
$car3 = imagecreatefromgif($characterarray[2].'.gif');
$car4 = imagecreatefromgif($characterarray[3].'.gif');
$car5 = imagecreatefromgif($characterarray[4].'.gif');
$car6 = imagecreatefromgif($characterarray[5].'.gif');
$car7 = imagecreatefromgif($characterarray[6].'.gif');
$car8 = imagecreatefromgif($characterarray[7].'.gif');

$dest_x = 17;  
$dest_y = 33;
$dest_x1 = 17;  
$dest_x2 = 43;  
$dest_x3 = 69;  
$dest_x4 = 95;  
$dest_x5 = 121;  
$dest_x6 = 147;  
$dest_x7 = 173;  
$dest_x8 = 199;  

imagecopymerge($image, $car1, $dest_x1, $dest_y, 0, 0, imagesx($car1), imagesy($car1), 100);
imagecopymerge($image, $car2, $dest_x2, $dest_y, 0, 0, imagesx($car2), imagesy($car2), 100);
imagecopymerge($image, $car3, $dest_x3, $dest_y, 0, 0, imagesx($car3), imagesy($car3), 100);
imagecopymerge($image, $car4, $dest_x4, $dest_y, 0, 0, imagesx($car4), imagesy($car4), 100);
imagecopymerge($image, $car5, $dest_x5, $dest_y, 0, 0, imagesx($car5), imagesy($car5), 100);
imagecopymerge($image, $car6, $dest_x6, $dest_y, 0, 0, imagesx($car6), imagesy($car6), 100);
imagecopymerge($image, $car7, $dest_x7, $dest_y, 0, 0, imagesx($car7), imagesy($car7), 100);
imagecopymerge($image, $car8, $dest_x8, $dest_y, 0, 0, imagesx($car8), imagesy($car8), 100);

imagejpeg($image);

    $filename = 

$characterarray[0].$characterarray[1].$characterarray[2].$characterarray[3].$characterarray[4].$characterarray[

5].$characterarray[6].$characterarray[7].".jpg";

    if (is_file($filename)) {
        readfile($filename);
        exit;
    }


    imagejpeg($image,$filename);
  
imagedestroy($image); 

imagedestroy($car1);
imagedestroy($car2);
imagedestroy($car3);
imagedestroy($car4);
imagedestroy($car5);
imagedestroy($car6);
imagedestroy($car7);
imagedestroy($car8);


?>

Link to comment
Share on other sites

Ok ive found out that the images that is creating is actuly ok its the image that is actuly displayed on the screen...

 

http://bkswindell.dyndns.org:8091/dev/project/trunk/php/test4.php?strings=256

 

http://bkswindell.dyndns.org:8091/dev/project/trunk/php/256.jpg

 

This is very weird. Its like its not able to complete the process for some reason.  But it works on every other image.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.