Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Working with images

Status
Not open for further replies.

JamesGMills

Programmer
Aug 15, 2005
157
GB
Hi,

Could someone point me into the direction of how to learn how to do this:

I am making an image gallery and only want to have one LARGE image file. However i want to use some script or whatever it is called to make a thumbnail out of the larger file... I am sure you know what i mean...

I am not after code i am simply after some info on that thing that you need to be able to do this...

Thank you!
 
look up the following commands on php.net
imagegetsize
imagecreatefromjpeg
imagecopyresampled
ini_set <-- you'll probably need to set your memory higher if it's a large image
imagejpeg
imagedestroy

Most everything else you'll need you can find off links from those commands. Anything else will be functionality or math you'll need to do yourself, or ask here again and someone here will give you a hand. GL and have fun doing it!
 
Thanks i have had a good look into everything but all i seem to be able to find are scripts to convert and save images.

What i wanted to do was be able to only have one large image on the server and then creat a thumb as and when i needed to.

It seems like the ways i have been looking into are good if you want to create a new image for example when the user was to upload a large image.

Can what i want to do be done?

Thanks
 
Right.... got it... i had no idea how to link to the image function!

Got a script that i can use as a basis and then edit...

imageresize.php?src=example.jpg&scale=2&quality=100

This is what i can use to call the function... (never done that before....)

Thanks for all your help.
 
I would not do it in the querystring, as that makes it very easy to manipulate.

I'd rather make a function and pass integers and then run a switch on the variables in the scope.

eg:
1: user uploads file
2: system generates thumb, via function it calls.

I would never allow the user to set thumb-size, as you would get a wierd design when people suddenly are having fun in theire admin-area.

Also, look up imagecreatetruecolor, as the other ones might give you thumbs which seem very "grey", eg. they lack color.

Olav Alexander Mjelde
Admin & Webmaster
 

this is how it works (example only) so the user can not actually edit anything as its in the php file...

<img src="resize_image.php?src=images/james_and_helen/james_and_helen_024.jpg&scale=6&quality=100" border="0">

which is just generated from a while loop...

There are two options i have and i think it will depend on if users will be able to upload images using form or if i will simple batch upload them with FTP...

If i upload them this is ok i think - do you not?

If they do then yes i think resize and save a large file and create and save a thum file.

Thank you...
 
hmm, so I can make a php script on my webpage:
<?php

for ($i = 0; $i < 99999999; $i++) {
echo "<img src=\"resize_image.php?src=images/james_and_helen/james_and_helen_024.jpg&scale=6&quality={$i}\">";
}

then I can go in my internet browser and disable that it should show images.

or do you check referrer??

Olav Alexander Mjelde
Admin & Webmaster
 
well if you view source of the page you can still see the

resize_image.php?src=images/james_and_helen/james_and_helen_ etc...

I guess the only thing that could be done is to check referrer on the resize_image page and just make sure its not blank.

What do you think about this way of working?
 
The ref field could, in fact, be blank as not all browsers will pass the ref data. Recently ran into that problem here at my office and some addons to IE see to help cause it as well.
 
Hummm interesting because i was going to say not many people will know how to do all that but then what about when users want to link to an image etc...

Going to have to give this some more thought. Thanks.
 
Do the scale and quality settings change picture to picture? If not you could code them into the script or into a configuration file somewhere.
 
No they are the same for every picture... they need to be set once...

They could just be hard coded into the resize_image file actually... no need to pass it through URL... that would stop users being able to change it...

Lots to think about and work on i think... thanks...
 
I would use htaccess and modify a script which I have :p
evolt.org has a searchfriendly script.

I modified that script, so it can extract values and add in arrays..

eg. user types in a "fake" url.
Im too tired to explain more, but if you search for threads by yours truly, and include evolt or searchfriendly in the search, you might find some samples Ive posted a looong time ago.

Olav Alexander Mjelde
Admin & Webmaster
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top