Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Resize and generate thumbnail?
Old 08-29-2007, 12:20 PM Resize and generate thumbnail?
Super Talker

Posts: 122
Name: Nate
Location: Orlando, FL
Trades: 0
Is it possible to make PHP do two things at once with images? For instance, I would like to create a system that resizes images to 800px wide, and at the same time generate a thumbnail 150x150...

I also need to figure out how to get this working in a MySQL database, so that when someone uploads the image, it upload the images to /images, and then the file names are stored in the MySQL database, and called up when a query is run. Suggestions? Thanks!!
__________________
Every time you use Internet Explorer, God kills a kitten.
NateL is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-29-2007, 12:32 PM Re: Resize and generate thumbnail?
trk247's Avatar
Novice Talker

Posts: 11
Trades: 0
It's very possible, try these for starters:
http://blazonry.com/scripting/upload-size.php
http://www.phpit.net/article/image-m...-php-gd-part2/
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by trk247; 08-29-2007 at 12:33 PM..
trk247 is offline
Reply With Quote
View Public Profile
 
Old 08-29-2007, 12:52 PM Re: Resize and generate thumbnail?
Super Talker

Posts: 122
Name: Nate
Location: Orlando, FL
Trades: 0
This is a small program that I'm writing to distribute to people who don't know much about anything web related. What are my options if their server does not support GD?
__________________
Every time you use Internet Explorer, God kills a kitten.
NateL is offline
Reply With Quote
View Public Profile
 
Old 08-29-2007, 01:32 PM Re: Resize and generate thumbnail?
trk247's Avatar
Novice Talker

Posts: 11
Trades: 0
Do you have imageMagic on your server? It does the same thing as GD.
http://www.imagemagick.org/script/index.php

If not, you could just upload the images as 800x800 and code the html retro style by proportionally altering the width and heights for the thumbnails.

Without imageMagick or GD, it might be pretty hard to pull that off.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by trk247; 08-29-2007 at 01:34 PM..
trk247 is offline
Reply With Quote
View Public Profile
 
Old 08-29-2007, 01:49 PM Re: Resize and generate thumbnail?
Super Talker

Posts: 122
Name: Nate
Location: Orlando, FL
Trades: 0
I agree. I'd like to write the program only once, but I'm not sure what kind of server these people have, so it looks like I may need to write the program at least twice...once for GD/ImageMagick, and once for uploading large images and thumbnails
another option is to tell people to move to my servers...but I dunno if that will work out well
__________________
Every time you use Internet Explorer, God kills a kitten.
NateL is offline
Reply With Quote
View Public Profile
 
Old 08-29-2007, 05:54 PM Re: Resize and generate thumbnail?
Novice Talker

Posts: 7
Name: Glen
Trades: 0
I use this to function to resize to an image file....

function resizeToFile ($sourcefile, $dest_x, $dest_y, $targetfile, $jpegqual)
{
/* Get the dimensions of the source picture */
$picsize=getimagesize("$sourcefile");

$source_x = $picsize[0];
$source_y = $picsize[1];
$source_id = imageCreateFromJPEG("$sourcefile");

/* Create a new image object (not neccessarily true colour) */

$target_id=imagecreatetruecolor($dest_x, $dest_y);

/* Resize the original picture and copy it into the just created image
object. Because of the lack of space I had to wrap the parameters to
several lines. I recommend putting them in one line in order keep your
code clean and readable */


$target_pic=imagecopyresampled($target_id,$source_ id, 0,0,0,0, $dest_x,$dest_y, $source_x,$source_y);

/* Create a jpeg with the quality of "$jpegqual" out of the
image object "$target_pic".
This will be saved as $targetfile */

imagejpeg ($target_id,"$targetfile",$jpegqual);

return true;
}

//now need to set images sizes....eg
$largex=600;
$largey=450;
$thumbx=120;
$thumby=90;

//now resize file...in my case $filenamelarge is the name of the move_uploaded_file

resizeToFile ($filenamelarge, $newx, $newy, $destfilename, 90);
resizeToFile ($filenamelarge, $newxb, $newyb, $destfilenameb, 100);


...hope it helps, can post the full script if you want...

G
poachedeggs is offline
Reply With Quote
View Public Profile
 
Old 08-29-2007, 06:04 PM Re: Resize and generate thumbnail?
Novice Talker

Posts: 7
Name: Glen
Trades: 0
sorry, forgot to add the following lines after pic size definitions...

$picsize2=getimagesize("$destfilename");
//now detect whether pic is portrait or landscape and define new sizes for pic
if ($picsize2[0]>$picsize2[1]) {$newx=$largex;$newxb=$thumbx;$newy=$largey;$newyb =$thumby;} else {$newx=$largey; $newxb=$thumby; $newy=$largex; $newyb=$thumbx;}
poachedeggs is offline
Reply With Quote
View Public Profile
 
Old 08-29-2007, 07:13 PM Re: Resize and generate thumbnail?
Skilled Talker

Posts: 62
Name: Tom Wright
Location: Brighton, UK
Trades: 0
If writing just one script is your concern, I'm sure there are ways of determining the availability of GD on the fly.
I'd definitely advise against using a pure html system if you can avoid it though - it'd be very heavy bandwidth-wise.
__________________
My site:
Please login or register to view this content. Registration is FREE
tomythius is offline
Reply With Quote
View Public Profile
 
Old 09-05-2007, 02:07 AM Re: Resize and generate thumbnail?
Super Talker

Posts: 122
Name: Nate
Location: Orlando, FL
Trades: 0
Quote:
Originally Posted by tomythius View Post
If writing just one script is your concern, I'm sure there are ways of determining the availability of GD on the fly.
I'd definitely advise against using a pure html system if you can avoid it though - it'd be very heavy bandwidth-wise.
It's a small program.

What other options are there besides writing it into an existing php page?
__________________
Every time you use Internet Explorer, God kills a kitten.
NateL is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Resize and generate thumbnail?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.30357 seconds with 12 queries