473,508 Members | 2,342 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP image Uploading along with thumbnail

13 New Member
hi,

i've this situations where user will upload images..my code works fine for uploading images.. but i need to create auto thumbnail picture (of the same image) whenever user upload images... help me how to create thumbnail picture..
is my question clear?

thk in advance
Apr 14 '07 #1
5 2034
Motoma
3,237 Recognized Expert Specialist
You can use the height and width attributes of the <img> tag to adjust the size of the image.

hi,

i've this situations where user will upload images..my code works fine for uploading images.. but i need to create auto thumbnail picture (of the same image) whenever user upload images... help me how to create thumbnail picture..
is my question clear?

thk in advance
Apr 14 '07 #2
Deejam
13 New Member
@ Motoma

here the page shows the all the images which user has uploaded, if i use the height and width to reduce the image display size, eventually the page will take much time to load...

hope i'm clear...

thkx for replying
Apr 15 '07 #3
cyberking
84 New Member
Hi Deejam

In that case, you can as well write your own image resizing function. Not a big deal. Get the size of the image using the getimagesize function. Store the return values in a variable. Perform reduction on the width and the height returned by the getimagesize function and then return the new reduced width and heigth to the width and height parameters in the img tag.

More if you need help
Regards
CyberKing
Apr 15 '07 #4
Motoma
3,237 Recognized Expert Specialist
Cyberking's method is valid; if you want to do more research on this method, you should look up the PHP GD functions.
Apr 16 '07 #5
Deejam
13 New Member
Thanks cyberking and Motoma...

here is the code for creating thumbnail to the uploading picture...

echo "Creating thumbnail for $filename <br />";
// Load image and get image size
$orgimg = imagecreatefromjpeg($filename);
$width = imagesx($orgimg);
$height = imagesy($orgimg);
// Setting new width and height for thumbnail size
$newwidth = 100; //any size as you wish
$newheight = floor($height*($newwidth/$width));
// Creating new temporary image
$tmpimg = imagecreatetruecolor($newwidth, $newheight);
// Copy and resize old image into new image
imagecopyresized($tmpimg, $orgimg, 0, 0, 0, 0, $newwidth, $newheight, $width, $height );
// Save thumbnail into a file
imagejpeg($tmpimg, $path_to_thumbs_dir.$filename);


i welcome any suggestion/correction...
Apr 16 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
2437
by: DH | last post by:
I have a "file upload form" that works OK, but I have been unsuccessful in my attempt to also resize the uploaded .JPG (if it is too wide), over-writing the original .JPG, and then create and save...
0
1789
by: doffer | last post by:
I want to make a portfoliosystem where user can register and get their own portfolio... I've started the developer work, but I'm stuck on the image upload part... I'm experiencing some problems...
2
4151
by: Faree | last post by:
Hi, I am a PHP Developer.can any one help me on image upload and display of that image.what i want is uploading an image to a directory ,displaying of that image as a thumbnail.when i...
0
1635
by: Duncan Welch | last post by:
I've got users uploading a file, which I then want resize, make a thumbnail out of, then delete. The image and thumbnail are working fine, but when I try to delete the image, I get an error: "The...
13
2333
by: Neo Geshel | last post by:
I have examined about 80+ different upload scripts on the 'net, both in VB and C#, and none seem to do what I need them to do. Perhaps someone here can point me somewhere that Google hasn't...
4
1446
by: hannes | last post by:
I have a problem with uploading images and creating thumbs from it. Not all the time, but sometimes, the full size image is completely uploaded and correct, while the thumbnail only builds a...
7
2350
by: xx75vulcan | last post by:
Hi, I've got a PHP Upload Form that works great, unless that is, the image your uploading has been modified through a photo editing software. Example: if I upload the image straight from a...
7
17035
by: mishrarajesh44 | last post by:
hii all Truly telling i hav got this code from net & i am finding error while running the code below.. code:- <?php $idir = "photo/"; // Path To Images Directory $tdir =...
10
7043
by: mishrarajesh44 | last post by:
hii all, I am facing a problem currently.. i have a script for image uploading and resizing.. the image uploading takes place properly for every size images.. but, the resizing works for...
0
7229
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
7129
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
7333
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
7398
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7502
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5637
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5057
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4716
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
428
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.