Jump to content

Image Resize


SieRobin

Recommended Posts

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:
[code]<?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();
}
?>[/code]

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
Link to comment
Share on other sites

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??
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.