Log in

View Full Version : Need help..... with....... PHP! :]

21-08-2005, 04:57 PM
oke, well I am building this little look-a-like blog site for myself.

Everything works so far.
Atm I am building a picture/foto page.
When I got a few pictures to add, I can run a little script, that reads the file info, and put that in the DB. When someone access the site, with the foto's it will see if the user is logged in, if so, it will get all the results from the DB, (onlythose that are not protected/prive foto's for my GF and I only). oke, that works so far.
Then it will create a little table (got to make the layout still.. so they are all placed underneath each other now) with a and a little thumbnail in between.

That same class, that gives the result of all the images, is also a class that can create thumbnails on-the-fly (GD2). so it does. BUT!
For somereason (on my localhost) he only can be called 2 times at once... (only 2 images are processed at the same time).

here is the code for it so far.. (its a bit big.. I know, and its far but finished)

class.php: (sorry was too huge to copy paste...)
and if you don't want to search the file... here is the code part I used to make the thumbs
* This function will make this class.php an image, with the given image
* location. Along with that, it will on-the-fly make a small thumb of the
* given image.
* @return Image ImageFile(PNG)
public function show_file_thumb() {

if ($this->picture_type == "gif")
$picture = imagecreatefromgif($this->picture_file);
if ($this->picture_type == "jpg" || $this->picture_type == "jpeg")
$picture = imagecreatefromjpeg($this->picture_file);
if ($this->picture_type == "png")
$picture = imagecreatefrompng($this->picture_file);

$photo_dimensions_width = imagesx($picture);
$photo_dimensions_height = imagesy($picture);

if ($photo_dimensions_width > $this->max_thumb OR $photo_dimensions_height > $this->max_thumb) {
if ($photo_dimensions_width == $photo_dimensions_height) {
$thumb_dimensions_width = $this->max_thumb;
$thumb_dimensions_height = $this->max_thumb;
elseif ($photo_dimensions_width > $photo_dimensions_height) {
$value = $photo_dimensions_width / $this->max_thumb;
$thumb_dimensions_width = $this->max_thumb;
$thumb_dimensions_height = round($photo_dimensions_height / $value);
} else {
$value = $photo_dimensions_height / $this->max_thumb;
$thumb_dimensions_height = $this->max_thumb;
$thumb_dimensions_width = round($photo_dimensions_width / $value);
} else {
$thumb_dimensions_width = $photo_dimensions_width;
$thumb_dimensions_height = $photo_dimensions_height;

$create_thumb = imagecreatetruecolor ($thumb_dimensions_width, $thumb_dimensions_height);

imagecopyresampled ($create_thumb, $picture, 0, 0, 0, 0, $thumb_dimensions_width, $thumb_dimensions_height, $photo_dimensions_width, $photo_dimensions_height);

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

Is this a coding issue? or is that I forgot something to set in my apache server?
(I am gonna make normal thumbnails, as the script is too slow anyway, but I still wouldl ike to know how it comes, only 2 are processes at one time...)

direct link to the site

as I said, might take a while for the pictures to show up

[edit] ffs, he doesnt like my code to be surrounded by code tags... ohwell.

21-08-2005, 06:34 PM
nvm, fixored it a bit... (well made the loading faster) I now use imagecopyresized insetad of imagecopyresampled