Current location: Hot Scripts Forums » Programming Languages » PHP » Resample an Image on upload


Resample an Image on upload

Reply
  #1 (permalink)  
Old 08-11-06, 02:43 PM
Deansatch Deansatch is offline
Coding Addict
 
Join Date: Jul 2006
Location: Northumberland
Posts: 375
Thanks: 0
Thanked 0 Times in 0 Posts
Resample an Image on upload

I have written a content management system which involves uploading pictures. Rather than limiting the file upload size which confuses people with basic computer knowledge because they can't resize their images, I would like the images to resample to a certain maximum width on upload.
eg. someone plugs their 5megapixel camera in, takes a picture off it and the uploads it. Obviously huge I want it to resample to about 400pixels wide keeping its proportions constrained.
Is this possible?
My upload code is as follows:
PHP Code:

error_reporting(E_ALL E_NOTICE);


require(
"../config/config.php");
require(
"../config/functions.php");
$my_session get_session();
$user_details check_client($my_session);
$connection mysql_connect($host,$usr,$pwd);

while (list(
$key$val) = @each($HTTP_POST_VARS)) { $val = ($val); $GLOBALS[$key] = $val; }
while (list(
$key$val) = @each($HTTP_GET_VARS)) { $val = ($val); $GLOBALS[$key] = $val; }
           
move_uploaded_file($_FILES['picture1']['tmp_name'],"latest.img");
        
$instr fopen("latest.img","rb");
        
$image addslashes(fread($instr,filesize("latest.img")));
        if (
strlen($instr) < 14900000) {
        
      
$update " update table_customers set picture1='$image' where username='$user_details'";
$query mysql_db_query($db$update$connection);
check_mysql($query);
client_message("Photo 1 Uploaded Sucessfully","If you would like to upload another photograph, choose another upload slot");


 } else {
                
$errmsg "Your photograph is too large! Please resize and try again.";
        }




__________________
Aye!

Last edited by Deansatch; 08-11-06 at 02:44 PM. Reason: missed the closing php tag
Reply With Quote
  #2 (permalink)  
Old 08-11-06, 02:50 PM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Image Upload Perms automatically set to 600 progress Perl 2 10-05-05 12:19 PM
ASP upload prob minority ASP 1 06-27-05 08:35 AM
image resize and upload ascanio PHP 0 06-25-05 06:37 PM
Image upload and if / else mdhall PHP 4 11-14-04 03:12 PM
Image Upload Reeps Script Requests 1 10-07-04 09:40 PM


All times are GMT -5. The time now is 07:23 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.