473,387 Members | 1,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Auto thumbnails

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
5 5179
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
"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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Ken | last post by:
I am in the process of designing my first web-site, and am having a problem with my picture gallery. My thumbnails are all different sizes, I would like them to be one size. The manual does not...
6
by: c d saunter | last post by:
Greetings All, In Widows Explorer there is a thumbnail view, where you see images as thumbnails. Applications such as MS Office and OpenOffice, when installed, cause their respective filetypes to...
4
by: Rednelle | last post by:
Greetings all, As a newbie, using Access 2000, I would appreciate advice on the best way to include pictures. I have developed a 'Home Inventory' database which can include jpeg thumbnails of...
3
by: Vagabond Software | last post by:
I'm trying to display thumbnail images in a Listview that look more like the Windows thumbnail view. Everything is working pretty good, but my thumbnails are decidedly not like the Windows...
1
by: Espen Evje | last post by:
Hi, I am trying to present the images in a folder as thumbnails in a dynamically created asp:table. I however do not want to save the thumbnails to disk, only show the images in this folder as...
6
by: Rich | last post by:
Hello, I want to simulate the dynamic thumbnail display of Windows Explorer (winxp) on a form or pannel container. If I place a picture box on my container form/pannel and dimension it to the...
4
by: Barely Audible | last post by:
Guys I was wondering if it was possible to have a js file that, when the page loaded, it automatically generated a a set of thumbnails from directory of the page on the web server? Or would...
5
by: JJ | last post by:
I have a gallery-like application. (The gallery will be actually presented in Flash, but the management (cms) of the images will be in asp.net. ) My question is, is it ok to create Thumbnail...
1
by: iswar | last post by:
hi friends asp.net(2.0) c# i am trying to create an image gallery in which all the uploaded image are converted into thumbnails and i want to bind these thumbnails into gridview. and on clicking...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.