Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 new image problems...
Index -> Programming, PHP -> PHP Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Amailer




PostPosted: Sun Nov 02, 2003 1:03 am   Post subject: new image problems...

code:

    $new_width = 90;
    $new_height = 90;

    $destimg=ImageCreate($new_width,$new_height) or die("Problem In Creating image");

    $srcimg=ImageCreateFromJPEG($im) or die("Problem In opening Source Image");

    imagecopyresized($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg)) or die("Problem In resizing");

    ImageJPEG($destimg,$im) or die("Problem In saving");

    imagedestroy($im);


WAHTS WRONG...WHATS WRONG...
Sponsor
Sponsor
Sponsor
sponsor
octopi




PostPosted: Sun Nov 02, 2003 2:38 pm   Post subject: (No subject)

$im is not defined....what error messages do you get?
Amailer




PostPosted: Sun Nov 02, 2003 5:17 pm   Post subject: (No subject)

Oh, hm it is...its... $im = "./img/test.jpg";

And no error messages :S!
:S
http://amailer.sourceforge.net/new_image.php
octopi




PostPosted: Sun Nov 02, 2003 6:17 pm   Post subject: (No subject)

what about your error logs?
Amailer




PostPosted: Sun Nov 02, 2003 6:23 pm   Post subject: (No subject)

Hmm, not on my server so...idk.
I think i got a diffrent gd dll then sourceforge. idk

Ill try it on my server brb

code:

[Sun Nov 02 00:14:45 2003] [error] [client 24.101.23.162] File does not exist: C:/Program Files/Apache Group/Apache2/htdocs/Avatar.jpg, referer: http://www.compsci.ca/v2/viewtopic.php?t=2057
[Sun Nov 02 00:18:57 2003] [warn] (OS 64)The specified network name is no longer available.  : winnt_accept: Asynchronous AcceptEx failed.
[Sun Nov 02 00:24:16 2003] [error] [client 64.68.82.18] File does not exist: C:/Program Files/Apache Group/Apache2/htdocs/robots.txt
[Sun Nov 02 00:26:22 2003] [error] [client 65.95.157.35] File does not exist: C:/Program Files/Apache Group/Apache2/htdocs/Avatar.jpg, referer: http://www.compsci.ca/v2/viewtopic.php?p=18271
[Sun Nov 02 00:32:54 2003] [error] [client 204.95.98.253] File does not exist: C:/Program Files/Apache Group/Apache2/htdocs/termix/Forum/robots.txt
[Sun Nov 02 00:34:36 2003] [error] [client 64.228.137.246] File does not exist: C:/Program Files/Apache Group/Apache2/htdocs/Avatar.jpg, referer: http://www.compsci.ca/v2/viewtopic.php?t=1653
[Sun Nov 02 01:28:15 2003] [error] [client 64.68.82.204] File does not exist: C:/Program Files/Apache Group/Apache2/htdocs/robots.txt
[Sun Nov 02 13:49:56 2003] [notice] Parent: Created child process 712
[Sun Nov 02 13:49:57 2003] [notice] Child 712: Child process is running
[Sun Nov 02 13:49:57 2003] [notice] Child 712: Acquired the start mutex.
[Sun Nov 02 13:49:57 2003] [notice] Child 712: Starting 250 worker threads.
[Sun Nov 02 17:18:12 2003] [error] [client 66.185.85.69] File does not exist: C:/Program Files/Apache Group/Apache2/htdocs/Avatar.jpg, referer: http://www.compsci.ca/v2/viewtopic.php?t=2155&highlight=
octopi




PostPosted: Sun Nov 02, 2003 6:26 pm   Post subject: (No subject)

Oh, sourceforge uses linux, so it doesn't use dll files.

Ask the admin's if there php version was compiled with gd support.

"Is php on your servers complied with gd?"

Or just put this in a file and see for your self
code:
<?phpinfo();?>


Check what version they have.
Amailer




PostPosted: Sun Nov 02, 2003 6:27 pm   Post subject: (No subject)

But it dont' wrk on my own server its self :S

and here,
http://amailer.sourceforge.net/phpinfo.php


HMM?
code:

[Sun Nov 02 17:18:12 2003] [error] [client 66.185.85.69] File does not exist: C:/Program Files/Apache Group/Apache2/htdocs/Avatar.jpg, referer: http://www.compsci.ca/v2/viewtopic.php?t=2155&highlight=
[Sun Nov 02 17:31:16 2003] [error] [client 205.211.56.77] File does not exist: C:/Program Files/Apache Group/Apache2/htdocs/Avatar.jpg, referer: http://www.compsci.ca/v2/viewtopic.php?t=2155

Why is it searchign for avatar.jpg???
avatar is a folder... C:/Program Files/Apache Group/Apache2/htdocs/img/Avatar/
octopi




PostPosted: Sun Nov 02, 2003 6:35 pm   Post subject: (No subject)

Post the whole code, cause you can't expect me to find a problem when you only post a small part of it.
Amailer




PostPosted: Sun Nov 02, 2003 6:38 pm   Post subject: (No subject)

code:

<?
function getRandomImage($dir,$type="random")
{
global $errors,$seed;

  if (is_dir($dir)) { 

  $fd = opendir($dir); 
  $images = array();

      while (($part = @readdir($fd)) == true) { 

          if ( eregi("(gif|jpg|png|jpeg|bmp)$",$part) ) {
              $images[] = $part;
          }
      }

    // adding this in case you want to return the image array
    if ($type == 'all') return $images;

    if ($seed !== true) {
      mt_srand ((double) microtime() * 1000000);
      $seed = true;
    }
     
      $key = mt_rand (0,sizeof($images)-1);
   
   $im = $dir . $images[$key];
       
    header("Content-type: image/jpeg");

    $new_width = 90;
    $new_height = 90;

    $destimg=ImageCreate($new_width,$new_height) or die("Problem In Creating image");

    $srcimg=ImageCreateFromJPEG($im) or die("Problem In opening Source Image");

    imagecopyresized($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg)) or die("Problem In resizing");

    ImageJPEG($destimg,$im) or die("Problem In saving");

    imagedestroy($im);

  } else {
      $errors[] = $dir.' is not a directory';
      return false;
  }
}


$dir = "./img/Avatar/";

getRandomImage($dir);

?>


In the images/avatar folder there are 3 images:
theonetokill-avatar.jpg
OneToKills2.jpg
admin-avatar.jpg

Basically it displays randome images that have been resized to 90x90 px
octopi




PostPosted: Sun Nov 02, 2003 6:40 pm   Post subject: (No subject)

Does images[] have any values.....if it doesn't then the program would just goto the Dir specified...and might try to add a .jpg extention to it. That would explain your error in the logs.
Amailer




PostPosted: Sun Nov 02, 2003 6:49 pm   Post subject: (No subject)

It does, it works prefectly with out creating an image, ill show you.

code:

<?
function getRandomImage($dir,$type="random")
{
global $errors,$seed;

  if (is_dir($dir)) { 

  $fd = opendir($dir); 
  $images = array();

      while (($part = @readdir($fd)) == true) { 

          if ( eregi("(gif|jpg|png|jpeg|bmp)$",$part) ) {
              $images[] = $part;
          }
      }

    // adding this in case you want to return the image array
    if ($type == 'all') return $images;

    if ($seed !== true) {
      mt_srand ((double) microtime() * 1000000);
      $seed = true;
    }
     
      $key = mt_rand (0,sizeof($images)-1);
   
   $im = $dir . $images[$key];
       
    header("Content-type: image/jpeg");

    $fs = fopen($im, 'rb');
    fpassthru($fs);
        exit;

  } else {
      $errors[] = $dir.' is not a directory';
      return false;
  }
}


$dir = "./img/Avatar/";

getRandomImage($dir);

?>


that way it works,
But, the other way it don't.

http://termix-zero.ath.cx/pictures/new_image.php
view its souce, i get:
code:

<br />
<b>Warning</b>:  imagedestroy(): supplied argument is not a valid Image resource in <b>C:\Program Files\Apache Group\Apache2\htdocs\pictures\new_image.php</b> on line <b>43</b><br />
Amailer




PostPosted: Sun Nov 02, 2003 7:00 pm   Post subject: (No subject)

Look...
code:

[Sun Nov 02 13:49:56 2003] [notice] Parent: Created child process 712
[Sun Nov 02 13:49:57 2003] [notice] Child 712: Child process is running
[Sun Nov 02 13:49:57 2003] [notice] Child 712: Acquired the start mutex.
[Sun Nov 02 13:49:57 2003] [notice] Child 712: Starting 250 worker threads.
[Sun Nov 02 17:18:12 2003] [error] [client 66.185.85.69] File does not exist: C:/Program Files/Apache Group/Apache2/htdocs/Avatar.jpg, referer: http://www.compsci.ca/v2/viewtopic.php?t=2155&highlight=
[Sun Nov 02 17:31:16 2003] [error] [client 205.211.56.77] File does not exist: C:/Program Files/Apache Group/Apache2/htdocs/Avatar.jpg, referer: http://www.compsci.ca/v2/viewtopic.php?t=2155
[Sun Nov 02 17:39:32 2003] [error] [client 64.231.193.26] File does not exist: C:/Program Files/Apache Group/Apache2/htdocs/Avatar.jpg, referer: http://www.compsci.ca/v2/viewtopic.php?t=2155
[Sun Nov 02 17:40:26 2003] [error] [client 192.168.1.1] File does not exist: C:/Program Files/Apache Group/Apache2/htdocs/Avatar.jpg, referer: http://www.compsci.ca/v2/viewtopic.php?t=2155
[Sun Nov 02 17:56:48 2003] [error] [client 192.168.1.1] Not a JPEG file: starts with 0x47 0x49
[Sun Nov 02 17:56:50 2003] [error] [client 192.168.1.1] Not a JPEG file: starts with 0x47 0x49
[Sun Nov 02 17:56:51 2003] [error] [client 192.168.1.1] Not a JPEG file: starts with 0xd0 0xcf
[Sun Nov 02 17:56:52 2003] [error] [client 192.168.1.1] Not a JPEG file: starts with 0x47 0x49
octopi




PostPosted: Sun Nov 02, 2003 7:28 pm   Post subject: (No subject)

Didn't you say $im was just a path name, and not an image resource?

Do you understand what imagedestory() does?
Amailer




PostPosted: Sun Nov 02, 2003 7:53 pm   Post subject: (No subject)

the $im has the the image (eg. ./img/avatar/image.jpg)

Either way, with and without the imagedestory() it does not work :SS:S
octopi




PostPosted: Sun Nov 02, 2003 10:57 pm   Post subject: (No subject)

Well...you were using imagedestory wrong...


Look at your error's its telling you the problem...your trying to open a Jpeg image, that isn't a jpeg image.

Theres nothing else I can do....you should check the paths, and stuff, and see exactly where its looking for the file, before you try and show the image.
Display posts from previous:   
   Index -> Programming, PHP -> PHP Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 18 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: