PHP Image Preloads

He has: 77 posts

Joined: Apr 2005

Hey, guys, I'm trying to design an image gallery for servers with PHP on safemode, so I've got a little delemna. I've taken care of resizing the images on screen and such, but I do so with Javascript and it only resizes what you see. In other words, the images are made smaller, but the entire image is loaded. I need to come up with a way that I can load the image on the server or only load the smaller version of the image. Any ideas?

Busy's picture

He has: 6,151 posts

Joined: May 2001

How about PHP's GD or ImageMavick and create a smaller version of the orginal for display. Happens on the fly or can be saved when uploaded

Greg K's picture

He has: 2,145 posts

Joined: Nov 2003

See:

http://www.php.net/gd

and in particular the funtion you probably want:
http://www.php.net/imagecopyresampled

but first use this to determine if you have GD available:
http://www.php.net/gd_info

-Greg

He has: 77 posts

Joined: Apr 2005

The idea is to make it so that the gallery can display in safe mode. Safe mode disables these quick fixes. Thanks for the effort but does anyone know how to do this without GD?

Greg K's picture

He has: 2,145 posts

Joined: Nov 2003

What is safe mode for PHP, what does it acheive? (I've heard of it, but not read what it is for).

Short of using GD, you would need to upload a thumbnail.

-Greg

PS. Wonder if there are any services that do this, pull the image from your server than sends one back out that is reaized. Being servers, on fast connection, for a dialup user, would still be faster.

He has: 77 posts

Joined: Apr 2005

Well, here's what I am capable of doing:

I can load the image into a file handle and I can echo the image, but then if I put any html or text in the same file, the image becomes a lot of gibberish like when you try to open an exe file in a text editor. I'm now trying to set it up so that it will load and edit the image and then save it as a thumbnail. This would happen every time that the administrater uploaded a new image. Obviously, I've got my work cut out for me.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.