By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,642 Members | 1,687 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,642 IT Pros & Developers. It's quick & easy.

Auto thumbnails

P: n/a
Hi,

[crossposted]

I'm putting together a website for a local estate agent.

One of the things they want to do is upload property
descriptions/prices/etc. plus a picture of the property which is for
sale.

I'd like to generate thumbnails of the pictures automatically either
once the data is uploaded (preferred) or when the relevant page is
delivered to the browser. Server-side scripting will most likely be
done in PHP.

Is this possible?

Lemming
--
Curiosity *may* have killed Schrodinger's cat.
http://goldcrossdata.co.uk/ ICQ: 8647501
Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On Mon, 20 Oct 2003 16:26:05 +0100, Lemming wrote:
Hi,

[crossposted]

I'm putting together a website for a local estate agent.

One of the things they want to do is upload property
descriptions/prices/etc. plus a picture of the property which is for sale.

I'd like to generate thumbnails of the pictures automatically either once
the data is uploaded (preferred) or when the relevant page is delivered to
the browser. Server-side scripting will most likely be done in PHP.

Is this possible?


Yes.

For more info, look at
GD functions -- can be built into PHP directly.
ImageMagick
NetPBM
Both IM and NetPBM must be accessed using passtrhu(), exec(), system()
or similar. NetPBM does the best job of manipulating images, IMO.
--
Jeffrey D. Silverman | jeffrey AT jhu DOT edu
Johns Hopkins University | Baltimore, MD
Website | http://www.wse.jhu.edu/newtnotes/

Jul 17 '05 #2

P: n/a
"Jeffrey Silverman" <je*****@jhu.edu> wrote:
On Mon, 20 Oct 2003 16:26:05 +0100, Lemming wrote:
I'd like to generate thumbnails of the pictures automatically either once
the data is uploaded (preferred) or when the relevant page is delivered to
the browser. Server-side scripting will most likely be done in PHP.

Is this possible?


Yes.

For more info, look at
GD functions -- can be built into PHP directly.
ImageMagick
NetPBM
Both IM and NetPBM must be accessed using passtrhu(), exec(), system()
or similar. NetPBM does the best job of manipulating images, IMO.


Excellent - many thanks.

Lemming
--
Curiosity *may* have killed Schrodinger's cat.
http://goldcrossdata.co.uk/ ICQ: 8647501
Jul 17 '05 #3

P: n/a
Lemming wrote:
Hi,

[crossposted]

I'm putting together a website for a local estate agent.

One of the things they want to do is upload property
descriptions/prices/etc. plus a picture of the property which is for
sale.

I'd like to generate thumbnails of the pictures automatically either
once the data is uploaded (preferred) or when the relevant page is
delivered to the browser. Server-side scripting will most likely be
done in PHP.

Is this possible?

Lemming


There's a tutorial on creating thumbnails using GD linked to the front
page of phpfreaks.com.

--
--
Lynn Wallace http://www.xmission.com/~lawall
"I'm not proud. We really haven't done everything we could to protect
our customers. Our products just aren't engineered for security."
--Microsoft VP in charge of Windows OS Development, Brian Valentine.

Jul 17 '05 #4

P: n/a
Raptor <me@attbi.com> wrote in message news:<3F**************@attbi.com>...
Lemming wrote:
Hi,

[crossposted]

I'm putting together a website for a local estate agent.

One of the things they want to do is upload property
descriptions/prices/etc. plus a picture of the property which is for
sale.

I'd like to generate thumbnails of the pictures automatically either
once the data is uploaded (preferred) or when the relevant page is
delivered to the browser. Server-side scripting will most likely be
done in PHP.

Is this possible?

Lemming


There's a tutorial on creating thumbnails using GD linked to the front
page of phpfreaks.com.

--


I made this one on my own.

<?php
function CheckUpload($filename)
{
$checkjpg = explode('.', $filename);
if($checkjpg[1] == 'jpg' || $checkjpg[1] == 'JPG' || $checkjpg[1] ==
'jpeg' || $checkjpg[1] == 'JPEG')
{
$size = getimagesize("/var/www/domains/factory8.com/r6/pics/uploaded/temp/$filename");
if($size[0] <= '540' && $size[1] <= '600')
{
$size = filesize("/var/www/domains/factory8.com/r6/pics/uploaded/temp/$filename");
if($size <= '102400')
{
if (!file_exists("/var/www/domains/factory8.com/r6/pics/uploaded/$filename"))
{
return TRUE;
}
else
{
die('Filename already exists.');
return FALSE;
}
}
else
{
die('File is greater than 100k');
return FALSE;
}
}
else
{
die('File resolution is to large');
return FALSE;
}
}
die('File must be a jpg, sorry.');
return FALSE;
}

function createThumb($filename,$uid, $extension)
{
$x = '150';
$y = '150';
$location = 'pics/uploaded/thumbnails/'.$uid.'.'.$extension;
$proportain = 1; //0 for no, 1 for yes
if (!$image=getimagesize($filename))
{
return FALSE; //return false if there is no image to create from
or it is not a image
}
else
{
if ($image['2'] == '1')
{
$im = imagecreatefromgif ($filename);
}
else if ($image['2'] == '2')
{
$im = imagecreatefromjpeg ($filename);
}
else
{
return FALSE; // return false if filetype is not of gif or
jpeg
}
if ($proportain == 1)
{
if ($image[0]<$image[1])
{
$x = $y * ($image[0]/$image[1]);
}
else
{
$y = $x / ($image[0]/$image[1]);
}
}
$newim = imagecreatetruecolor($x, $y);
ImageCopyResampled($newim, $im, 0, 0, 0, 0, $x, $y, $image[0],
$image[1]);
imagejpeg($newim, $location);
imagedestroy ($im);
imagedestroy ($newim);
return TRUE;
}
}
?>
--
Uploading file...<br>
<?php
if($file_name !="")
{
copy ("$file", "pics/uploaded/temp/$file_name")
or die("Could not copy file.");
}
else {die("No file specified.");}
?>
Checking file...<br>
<?php
$checkfile = CheckUpload($file_name);
?>
Putting in permanent place...<br>
<?php
copy("$file", "/var/www/domains/factory8.com/r6/pics/uploaded/$file_name");
?>
Creating thumbnail file...<br>
<?php
$fileinfo = explode('.', "$file_name");
$thumbcreated = createThumb("pics/uploaded/$file_name","$fileinfo[0]","$fileinfo[1]");
?>
Adding to the random picture list...<br>
<?php
$dbconn = mysql_connect("localhost", "username", "password");
mysql_select_db("factory8_com");
$addtodb = mysql_query("INSERT INTO bikepics (filename, comment,
owner, ipaddy) VALUES('$file_name', '$comment', '$owner',
'$REMOTE_ADDR')");
mysql_close($dbconn);
?>
<b>Done!</b><br>
<?php
print("
<img src='pics/uploaded/$file_name'><br><img
src='pics/uploaded/thumbnails/$file_name'>
");
?>

--

only bad part, is i forgot to delete the pictures in the temp
directory. :-P
Jul 17 '05 #5

P: n/a
Raptor <me@attbi.com> wrote in message news:<3F**************@attbi.com>...
Lemming wrote:
Hi,

[crossposted]

I'm putting together a website for a local estate agent.

One of the things they want to do is upload property
descriptions/prices/etc. plus a picture of the property which is for
sale.

I'd like to generate thumbnails of the pictures automatically either
once the data is uploaded (preferred) or when the relevant page is
delivered to the browser. Server-side scripting will most likely be
done in PHP.

Is this possible?

Lemming


There's a tutorial on creating thumbnails using GD linked to the front
page of phpfreaks.com.

--


Oh, you can see a working example here.
http://www.factory8.com/r6/
Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.