creating thumbnails

images php coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
User avatar
L33R
New php-forum User
New php-forum User
Posts: 143
Joined: Fri Dec 30, 2011 4:27 am
Location: Liverpool

Mon Apr 23, 2012 4:14 am

just set the width & height of the img . Then link to the page showing the image in its full size.

Code: Select all

<html>
<head>
	<title>test</title>
<body>
	<a href="image_view.html"><img src="images/50868449.jpg" width="100" height="100"></a>
</body>
	
</head>
</html>

on the other page :

Code: Select all

<html>
<head>
	<title>test</title>
<body>
	<img src="images/50868449.jpg">

</body>
	
</head>
</html>

User avatar
JordanMRichards
New php-forum User
New php-forum User
Posts: 81
Joined: Mon Apr 23, 2012 7:43 am
Contact:

Wed Apr 25, 2012 6:43 am

Hey SM,
I think I may have solved your issue (if I've understood correctly what you were looking for.)

I coded this bit up, it's dynamic too!

Code: Select all

<html>
<head>
</head>
<body>
<?php
//do your query and then set the image to the result of the query you wanted to doing your SQL database
$imageurl=$query_result;  // Set $query_result to the name of the variable you set to the result.
$height = 150;//height per image;
$width = 150; //width per image;

echo "<img src='".$imageurl."' height='".$height."' width='".$width."'></img>";
?>

</body>
</html>
And there you have it :)

Hope it helped!
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
14 Year Old Programmer & Graphic Artist, Confident and Courageous
Image

User avatar
egami
php-forum GURU
php-forum GURU
Posts: 2192
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Wed Apr 25, 2012 9:08 am

the height and length of the image doesn't make it a thumbnail, it only displays it smaller. The full size image is sent to the browser, thus spending bandwidth and wait-time.

in order to make a real thumbnail, you'll have to investigate php.net/image_create

User avatar
JordanMRichards
New php-forum User
New php-forum User
Posts: 81
Joined: Mon Apr 23, 2012 7:43 am
Contact:

Wed Apr 25, 2012 11:16 am

egami, ah yes I see your point.

Here's some nice videos explaining how to create a thumbnail. (in order)

http://www.youtube.com/watch?v=sBGpp5-GBdM
http://www.youtube.com/watch?v=e_uD7NCSHfM
http://www.youtube.com/watch?v=cRwziqA6fR4

Hope this helps :)

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
14 Year Old Programmer & Graphic Artist, Confident and Courageous
Image

pewe
New php-forum User
New php-forum User
Posts: 16
Joined: Fri May 25, 2012 6:05 am

Fri May 25, 2012 6:08 am

Are your images photographs (jpg) or other types?

User avatar
Nullsig
php-forum Fan User
php-forum Fan User
Posts: 979
Joined: Thu Feb 17, 2011 6:52 am
Location: Racine, WI

Fri May 25, 2012 6:55 am

This is all you need for creating thumbs:
http://www.white-hat-web-design.co.uk/b ... -with-php/

The class accommodates png, gif and jpg files. It will allow you to resize based on a required height or width or just by defining how much smaller (or bigger) you want the file.

pewe
New php-forum User
New php-forum User
Posts: 16
Joined: Fri May 25, 2012 6:05 am

Fri May 25, 2012 7:16 am

Really useful post Nullsig. Thanks - I will find that useful.

The reason I asked about photographs is that (as I understand it) when most cameras take a pictures and the RAW image is converted in the camera to a jpg, most internal camera software systems create and store a thumbnail in the jpg.

This thumbnail can be extracted from the jpg and displayed as a link to the full size image using PHP.

I have a small 'gallery' script that does this - although I don't understand the coding :oops:

Post Reply