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
imagecreatefromjpeg not working?
Old 10-04-2009, 09:49 AM imagecreatefromjpeg not working?
phpmysqlnewbie's Avatar
Junior Talker

Posts: 2
Name: Howard
Trades: 0
hi, my first post here

so i am having a problem in this line of code...
Code:
    $display = imagecreatefromjpeg("$dir/$image");  // Read all the images into an array.
in the display cell it doesnt display the image. it gives me "Resource id #12".

the file name and file size cells display the correct info and the javascript displays the correct image...

what am i doing wrong?

i am using php 5+ and gd 2+ is enabled.

thanks. full code follows.

Code:
<div align="center">Click on an image to view it in a separate window.</div><br />
<table align="center" cellspacing="5" cellpadding="5" border="1">
   <tr>
      <td align="center"><b>Image</b></td>
      <td align="center"><b>Image Name</b></td>
      <td align="center"><b>Image Size</b></td>
   </tr>
<?php # images.php
// This script lists the images in the uploads directory.

$dir = 'uploads'; // Define the directory to view.

$files = scandir($dir); // Read all the images into an array.

// Display each image caption as a link to the JavaScript function.
foreach ($files as $image) {

   if (substr($image, 0, 1) != '.') { // Ignore anything starting with a period.

      // Get the image's size in pixels.
      $image_size = getimagesize("$dir/$image");

      // Calculate the image's size in kilobytes.
      $file_size = round ( (filesize ("$dir/$image")) / 1024) . "kb";

    // display gif
    $display = imagecreatefromjpeg("$dir/$image"); // Read all the images into an array.

      // Print the information.
      echo "<tr>
         <td>$display</td>
         <td><a href=\"javascript: create_window('$dir/$image',$image_size[0],$image_size[1])\">$image</a></td>
         <td>$file_size</td>
      </tr>";

   } // End of the IF.

} // End of the foreach loop.

?>
</table>
__________________
newbie
php 5+, mysql 5+, apache 1.33
phpmysqlnewbie is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-04-2009, 07:01 PM Re: imagecreatefromjpeg not working?
phpmysqlnewbie's Avatar
Junior Talker

Posts: 2
Name: Howard
Trades: 0
so it turns out i was missing some simple html...
Code:
         <td><img src='$dir/$image' /></td>
i didnt need to use $display in the td.

all working now.
__________________
newbie
php 5+, mysql 5+, apache 1.33
phpmysqlnewbie is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to imagecreatefromjpeg not working?
 

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.59089 seconds with 12 queries