Jump to content


Photo

Image Resize


  • Please log in to reply
31 replies to this topic

#21 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 26 April 2006 - 05:31 PM

The source looks ok. Look at the generated HTML to see if the <img> tag is being created correctly.

Ken

#22 SieRobin

SieRobin
  • Members
  • PipPipPip
  • Advanced Member
  • 212 posts
  • LocationNew Jersey

Posted 26 April 2006 - 05:51 PM

All I did was change what you put into what was needed for the img tag. Ehmn, but let me double check it.

What I don't get is how is image.php associated with forum.php when it really isn't being a link clicked for the $_GET situation?

#23 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 26 April 2006 - 06:04 PM

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]What I don't get is how is image.php associated with forum.php when it really isn't being a link clicked for the $_GET situation?[/quote]

This code in the <img> tag is what invokes the script.
<img src='image.php?img=userimages/$stats3[uimage]' border='0'>
with the get method.

Ken

#24 SieRobin

SieRobin
  • Members
  • PipPipPip
  • Advanced Member
  • 212 posts
  • LocationNew Jersey

Posted 26 April 2006 - 06:15 PM

Doesn't seem to be working though, or else I suppose it would be pulling the information from the file.

I don't have to do an include do I?

#25 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 26 April 2006 - 06:33 PM

Did you do this:
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Look at the generated HTML to see if the <img> tag is being created correctly.[/quote]

If the generated code references image.php with the correct parameters, you will have to add debug statements to image.php. These can't write the information to the screen, but will have to write to a files.

[a href=\"http://www.rutgerspromenaders.org/pictures/index.php?d=./dances/2006/0402\" target=\"_blank\"]This[/a] site that I wrote uses a similar mechanism. It's a picture gallery, but the concept is the same. If you do a "show source" and scroll down towards the end you will see the <img> tags.

Ken

#26 SieRobin

SieRobin
  • Members
  • PipPipPip
  • Advanced Member
  • 212 posts
  • LocationNew Jersey

Posted 26 April 2006 - 06:55 PM

I did view source, the IMG tag looks like this for my picture.

<img src='image.php?img=userimages/me.jpg' border='0'>

Other then that, I'm not sure what you mean, sorry :\

#27 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 26 April 2006 - 07:13 PM

Ok, you want to put debug statements into the image.php file. But those statements can't write to the screen. They should write to a file.

What type of platform are you using? Windows or Unix (linux)

Here's how I would do it:
<?php
function write_debug($fp,date('Y-m-d G:i:s') . $str) {
   f write($fp,$str . "\n");
}

session_start();
$dbg = (isset($_GET['dbg']))?true:false;
if ($dbg) {
    $fp = f open('image_debug.txt','a');
    write_debug($fp,' --  Entering image.php');
    write_debug($fp,' -- $_GET --');
    write_debug($fp,print_r($_GET,true));
    f close($fp);
}
if (isset($_GET['img'])) {
// $img_name = "userimages/$pstats3[uimage]"; // <--- this statement is wrong -- my mistake sorry
   $img_name = $_GET['img'];
$max_width    = 150;
$max_height   = 150;
$size=getimagesize($img_name);
$width_ratio=($size[0] / $max_width);
$height_ratio =($size[1] / $max_height);

if($width_ratio>=$height_ratio)
{
   $ratio=$width_ratio;
}
else
{
   $ratio=$height_ratio;
}
$new_width=($size[0] / $ratio);
$new_height=($size[1] / $ratio);
header("Content-Type: image/jpeg");
$src_img = imagecreatefromjpeg($img_name);
$thumb = imagecreatetruecolor($new_width,$new_height);
imagecopyresampled($thumb, $src_img, 0,0,0,0,($new_width-1),($new_height-1),$size[0],$size[1]);
imagejpeg($thumb);
imagedestroy($src_img);
imagedestroy($thumb);
exit();
}
?>

While I was added the debug code to your image.php I noticed what the problem is. See the comment above with the "<---" in it.

The next line is the corrected line.

If changing that line works, you don't have to put in the debugging lines.

In the debug area I had to write the file functions with a space in them.

Ken

#28 SieRobin

SieRobin
  • Members
  • PipPipPip
  • Advanced Member
  • 212 posts
  • LocationNew Jersey

Posted 26 April 2006 - 07:20 PM

ahha, it works :] Thank ya!

#29 SieRobin

SieRobin
  • Members
  • PipPipPip
  • Advanced Member
  • 212 posts
  • LocationNew Jersey

Posted 26 April 2006 - 07:32 PM

Just one more question, I'm pretty sure it's easy to answer.. well since the only thing the code seems to accept is JPEG is there a way to allow GIF and PNG?

#30 SieRobin

SieRobin
  • Members
  • PipPipPip
  • Advanced Member
  • 212 posts
  • LocationNew Jersey

Posted 27 April 2006 - 04:05 AM

How exactly can I make it also accept GIF files and not just JPEG? Because, right now it will only display if it's in JPEG format.

#31 darga333

darga333
  • Members
  • PipPipPip
  • Advanced Member
  • 53 posts

Posted 27 April 2006 - 04:59 AM

forgive me if i am wrong but i would think you would just need to modify this line

header("Content-Type: image/jpeg");

i dont know the syntax but i would make it something like this

header("Content-Type: image/jpeg/JPEG/GIF/gif/PNG/png");

does that work??


#32 SieRobin

SieRobin
  • Members
  • PipPipPip
  • Advanced Member
  • 212 posts
  • LocationNew Jersey

Posted 27 April 2006 - 01:31 PM

My server is down right now but, I don't think that'd work since, it's asking it to createfromjpeg.. now if I were to put createfromgif it would allow all GIF extensions, but I can try it, never hurt to try.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users