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
https://forums.phpfreaks.com/topic/8329-image-resize/page/2/#findComment-31059
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.