Bluehost.com Web Hosting $6.95

Images On-Fly

This is a discussion on Images On-Fly within the PHP General forums, part of the PHP Programming Forums category; Hallo People, I have one problem with creating images on-fly. Therefore I created 2 files: 1. resize_image.php with ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-03-2003
Dejan Dujak
 
Posts: n/a
Default Images On-Fly

Hallo People,



I have one problem with creating images on-fly.

Therefore I created 2 files:

1. resize_image.php with the following

<?php

if (!$max_width)

$max_width = 150;

if (!$max_height)

$max_height = 100;

$size = GetImageSize($image);

$width = $size[0];

$height = $size[1];

$x_ratio = $max_width / $width;

$y_ratio = $max_height / $height;

if ( ($width <= $max_width) && ($height <= $max_height) ) {

$tn_width = $width;

$tn_height = $height;

}

else if (($x_ratio * $height) < $max_height) {

$tn_height = ceil($x_ratio * $height);

$tn_width = $max_width;

}

else {

$tn_width = ceil($y_ratio * $width);

$tn_height = $max_height;

}

$src = ImageCreateFromJpeg($image);

$dst = ImageCreate($tn_width,$tn_height);

ImageCopyResized($dst, $src, 0, 0, 0, 0,

$tn_width,$tn_height,$width,$height);

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

ImageJpeg($dst, null, -1);

ImageDestroy($src);

ImageDestroy($dst);

?>

AND

2. filex.php .In that file i read from database where the image is stored en

then i show small images(thumbnails).

thet part of the code is :

<?php do { ?>

<tr>

<td width="156" height="32" valign="top"><?php echo

$row_rsSubGroup['name']; ?></td>

<td colspan="2" valign="top"><?php

$fotolink="../dbtest/".$row_rsSubGroup['image_1']);

echo "<IMG

SRC=\"resize_image.php?image=$fotolink\">";

?>

</td>

</tr>

<?php } while ($row_rsSubGroup = mysql_fetch_assoc($rsSubGroup)); ?>





This doesn't WORK. Please HELP.
Reply With Quote
  #2 (permalink)  
Old 12-03-2003
Dejan Dujak
 
Posts: n/a
Default Re: Images On-Fly

My entire page will then not work. Apperently it contains then error. If i

do delete that part of the php code it works just fine.

"Dejan Dujak" <dejan.dujak@corusgroup.com> wrote in message
news:20031203094234.82936.qmail@pb1.pair.com...
> Hallo People,
>
>
>
> I have one problem with creating images on-fly.
>
> Therefore I created 2 files:
>
> 1. resize_image.php with the following
>
> <?php
>
> if (!$max_width)
>
> $max_width = 150;
>
> if (!$max_height)
>
> $max_height = 100;
>
> $size = GetImageSize($image);
>
> $width = $size[0];
>
> $height = $size[1];
>
> $x_ratio = $max_width / $width;
>
> $y_ratio = $max_height / $height;
>
> if ( ($width <= $max_width) && ($height <= $max_height) ) {
>
> $tn_width = $width;
>
> $tn_height = $height;
>
> }
>
> else if (($x_ratio * $height) < $max_height) {
>
> $tn_height = ceil($x_ratio * $height);
>
> $tn_width = $max_width;
>
> }
>
> else {
>
> $tn_width = ceil($y_ratio * $width);
>
> $tn_height = $max_height;
>
> }
>
> $src = ImageCreateFromJpeg($image);
>
> $dst = ImageCreate($tn_width,$tn_height);
>
> ImageCopyResized($dst, $src, 0, 0, 0, 0,
>
> $tn_width,$tn_height,$width,$height);
>
> header("Content-type: image/jpeg");
>
> ImageJpeg($dst, null, -1);
>
> ImageDestroy($src);
>
> ImageDestroy($dst);
>
> ?>
>
> AND
>
> 2. filex.php .In that file i read from database where the image is stored

en
>
> then i show small images(thumbnails).
>
> thet part of the code is :
>
> <?php do { ?>
>
> <tr>
>
> <td width="156" height="32" valign="top"><?php echo
>
> $row_rsSubGroup['name']; ?></td>
>
> <td colspan="2" valign="top"><?php
>
> $fotolink="../dbtest/".$row_rsSubGroup['image_1']);
>
> echo "<IMG
>
> SRC=\"resize_image.php?image=$fotolink\">";
>
> ?>
>
> </td>
>
> </tr>
>
> <?php } while ($row_rsSubGroup = mysql_fetch_assoc($rsSubGroup)); ?>
>
>
>
>
>
> This doesn't WORK. Please HELP.

Reply With Quote
  #3 (permalink)  
Old 12-03-2003
Jason Wong
 
Posts: n/a
Default Re: [PHP] Re: Images On-Fly

On Wednesday 03 December 2003 19:26, Dejan Dujak wrote:
> My entire page will then not work. Apperently it contains then error. If i
>
> do delete that part of the php code it works just fine.


So turn on FULL error reporting and find out what the error is.

--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
Whistler's mother is off her rocker.
*/
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 05:43 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0