Error 200 when certain PHP is used

  • Truce
  • Guru
  • Guru
  • Truce
  • Posts: 1477
  • Loc: Washington DC

Post 3+ Months Ago

I recently installed Abyss Web Server, PHP 5.0.3, and mySQL. I am trying to set up a php script to resize all of the images in a directory. When I visit the script, I get an error 200 (ok). I remove some of the php code that is resizing the image with imagecreatetruecolor and imagecopyresample and the code works, but doesnt resize the images (obviously).

I don't know what is wrong here. Any ideas? I already uncommented the GD library dll and put it in the folder with php and it didnt help.

PLEASE HELP!
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

What version of the GD library are you using? I pretty much assume you have the lastest release:
http://www.boutell.com/gd/
2.0.33


I guess the second question I would have is if the code you are writing is compatable with PHP 5.0.3


From a logical perspective, if you remove code and it works, and you add the code and it doesn't, then the problem lies in the code you added (could be typos or version compatability or just simply overlooking the obvious? *shrugs -- just throwing out thoughts.)
  • Truce
  • Guru
  • Guru
  • Truce
  • Posts: 1477
  • Loc: Washington DC

Post 3+ Months Ago

Well, I downloaded PHP like 2 days ago and it includes the file for GD. I am almost 100% sure it is 2.0.33

The code is this:
PHP Code: [ Select ]
 
<html>
 
<head><title>Test Site</title></head>
 
<body>
 
Server Running....
 
</body>
 
</html>
 
<?
 
 
 
$dir_path = 'pix';
 
$dir = opendir($dir_path);
 
$i = 0;
 
while (false !== ($file = readdir($dir))) {
 
   $file[$i] = $file;
 
   $i++;
 
}
 
closedir($dir);
 
 
 
$id = mt_rand(0, ($i-1))
 
$filename = "$dir_path/$file[$id]";
 
resizeJPG($filename, 400);
 
function resizeJPG($jpgFile, $width) {
 
 
 
   // Get new dimensions
 
   list($width_orig, $height_orig) = getimagesize($jpgFile);
 
   $height = (int) (($width / $width_orig) * $height_orig);
 
 
 
   // Resample
 
   $image_p = imagecreatetruecolor($width, $height);
 
   $image = imagecreatefromjpeg($jpgFile);
 
   imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
 
 
 
   // Output
 
   imagejpeg($image_p, $jpgFile, 100);
 
 
 
}
 
 
 
?>
 
 
  1.  
  2. <html>
  3.  
  4. <head><title>Test Site</title></head>
  5.  
  6. <body>
  7.  
  8. Server Running....
  9.  
  10. </body>
  11.  
  12. </html>
  13.  
  14. <?
  15.  
  16.  
  17.  
  18. $dir_path = 'pix';
  19.  
  20. $dir = opendir($dir_path);
  21.  
  22. $i = 0;
  23.  
  24. while (false !== ($file = readdir($dir))) {
  25.  
  26.    $file[$i] = $file;
  27.  
  28.    $i++;
  29.  
  30. }
  31.  
  32. closedir($dir);
  33.  
  34.  
  35.  
  36. $id = mt_rand(0, ($i-1))
  37.  
  38. $filename = "$dir_path/$file[$id]";
  39.  
  40. resizeJPG($filename, 400);
  41.  
  42. function resizeJPG($jpgFile, $width) {
  43.  
  44.  
  45.  
  46.    // Get new dimensions
  47.  
  48.    list($width_orig, $height_orig) = getimagesize($jpgFile);
  49.  
  50.    $height = (int) (($width / $width_orig) * $height_orig);
  51.  
  52.  
  53.  
  54.    // Resample
  55.  
  56.    $image_p = imagecreatetruecolor($width, $height);
  57.  
  58.    $image = imagecreatefromjpeg($jpgFile);
  59.  
  60.    imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
  61.  
  62.  
  63.  
  64.    // Output
  65.  
  66.    imagejpeg($image_p, $jpgFile, 100);
  67.  
  68.  
  69.  
  70. }
  71.  
  72.  
  73.  
  74. ?>
  75.  
  76.  


The code works when I remove the user defined function and the call to it.[/code]

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 16 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.