Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 12-12-2004, 03:22 PM   #1 (permalink)
falsepride
Regular Contributor
 
Join Date: Oct 2004
Posts: 207
falsepride is on a distinguished road
image work

i was looking at some php tutorial about water marking images on the fly. i dont know much about it yet, but is it possible to take an image and reduce the smallest length to 65px and keep it proportional and bascically make a thumbnail?
falsepride is offline   Reply With Quote
Old 12-12-2004, 05:42 PM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,475
sde is on a distinguished road
yes, if i have time tonight, i'll post some code, .. if not, i'll definately get it here tomorrow.
__________________
Mike
sde is offline   Reply With Quote
Old 12-13-2004, 06:18 PM   #3 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,475
sde is on a distinguished road
this is a function i wrote to upload an image, create a thumb with a height of 80 and resizes the width proportionately. it upload the image and names the thumb with a _t at the end. hope this helps.

$filename would be the temporary file name ( $_FILES['somefile']['tmp_name'] )
$name would be what you want it to be named
PHP Code:
<?
function getRootPath(){
  return 
"/home/user/public_html/";
}

function 
uploadPhoto($filename,$name){
  
$name stripslashes($name);
  list(
$width$height) = getimagesize($filename);
  
  
$percent 80 $height;
  
  
$new_width $width $percent;
  
$new_height $height $percent;
  
  
// Resample
  
$image_p imagecreatetruecolor($new_width$new_height);
  
$image imagecreatefromjpeg($filename);
  
imagecopyresampled($image_p$image0000$new_width$new_height$width$height);
  
  
$newfile getRootPath()."images/photos/".$name;
  
move_uploaded_file($filename,$newfile);
  
chmod($newfile0644);
  
  
$array explode(".",$name);
  
imagejpeg($image_pgetRootPath()."images/photos/".$array[0]."_t.".$array[1]);
}
?>
__________________
Mike
sde is offline   Reply With Quote
Old 12-13-2004, 06:25 PM   #4 (permalink)
falsepride
Regular Contributor
 
Join Date: Oct 2004
Posts: 207
falsepride is on a distinguished road
thanks this will come in handy, once i figure out what my darn problem with listing my pictures directoris in php.
falsepride is offline   Reply With Quote
Reply

Bookmarks

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Small modification needed on image flipping JavaScript Epsilon HTML, XML, Javascript, AJAX 0 08-31-2004 05:06 PM
Finding the size of an image? Epsilon PHP 2 06-22-2003 02:23 PM
I am a newb, how do you set multiple parts of an image as a link? I sniper baby HTML, XML, Javascript, AJAX 5 02-10-2003 06:40 PM
Stable Graphical FTP Client, HTML editor, & Image Manipulation for RedHat 7.3? Admin Linux / BSD / OS X 2 08-30-2002 04:55 PM


All times are GMT -8. The time now is 07:08 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting