PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 24th, 2004, 04:40 AM
aron aron is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: brisbane
Posts: 42 aron User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 9 m 35 sec
Reputation Power: 5
help with converting image resize script from image magic to gd

Hi All, i have made this script already using imagemagic, but have just relised the server runs gd librarys, i know this script works in image magic (i have used it elsewhere) was wondering if somone could help me convert it to use gd please.

PHP Code:
//Image Magick 
$rndnum rand(10,999999); 
exec("C:\imagemagick\convert.exe -resize 800 ".$new_file." ".$path.$rndnum.$id."minus_01".".jpg"); 
exec("C:\imagemagick\convert.exe -resize 420 ".$new_file." ".$path.$rndnum.$id."minus_02".".jpg"); 
exec("C:\imagemagick\convert.exe -resize 105 ".$new_file." ".$path.$rndnum.$id."minus_03".".jpg"); 
exec("C:\imagemagick\convert.exe -resize 72 ".$new_file." ".$path.$rndnum.$id."minus_04".".jpg"); 
$dbsave $rndnum.$id
//print "<br>Thumbnail: ".$path."thumb".$rndnum.".jpg"; 

//deletes original image 
unlink($new_file); 


thats the image magic resize bit.

if you need the entire script here it is.

PHP Code:
<? 
//header('Refresh: 2; URL="register_test.php'); 
$path "C:/path to image upload folder/"
//define("C_FILEPATH", "C:/path to image upload folder/"); 
$max_size 1048576
$id $_GET['id']; 
//chmod($path, 0777); 

if (!isset($HTTP_POST_FILES['userfile'])) die ("No image selected.");  

if  (
is_uploaded_file($HTTP_POST_FILES['userfile']['tm
p_name'
])) { 

if (
$HTTP_POST_FILES['userfile']['size']>$max_size) { die("The file is too big<br>\n"); } 
if ((
$HTTP_POST_FILES['userfile']['type']=="image/gif") || ($HTTP_POST_FILES['userfile']['type']=="image/pjpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/jpeg")) { 

if (
file_exists($path $HTTP_POST_FILES['userfile']['name'])) { die("The file already exists<br>\n");} 
$tmp_file $HTTP_POST_FILES['userfile']['tmp_name']; 
$new_file $path.$HTTP_POST_FILES['userfile']['name']; 

$res copy($tmp_file,$new_file); 

if (!isset(
$res)) { die("Upload Failed!<br>"); } 
echo 
"Upload Sucessful<br>Redirecting back to Your Details.<br>\n"

echo 
"File Name: ".$path.$HTTP_POST_FILES['userfile']['name']."<br>\n"
echo 
"File Size: ".$HTTP_POST_FILES['userfile']['size']." bytes<br>\n"
echo 
"File Type: ".$HTTP_POST_FILES['userfile']['type']."<br>\n"

//Image Magick 
$rndnum rand(10,999999); 
exec("C:\imagemagick\convert.exe -resize 800 ".$new_file." ".$path.$rndnum.$id."minus_01".".jpg"); 
exec("C:\imagemagick\convert.exe -resize 420 ".$new_file." ".$path.$rndnum.$id."minus_02".".jpg"); 
exec("C:\imagemagick\convert.exe -resize 105 ".$new_file." ".$path.$rndnum.$id."minus_03".".jpg"); 
exec("C:\imagemagick\convert.exe -resize 72 ".$new_file." ".$path.$rndnum.$id."minus_04".".jpg"); 
$dbsave $rndnum.$id
//print "<br>Thumbnail: ".$path."thumb".$rndnum.".jpg"; 

//deletes original image 
unlink($new_file); 

//insert images into database 
$connection mysql_connect("server","usernmae","password") or die('Could not connect to the database server');  
$db mysql_select_db("database"$connection) or die ("Unable to select database.");  
$sql "INSERT into images (listing_id,url) values('$id', '$dbsave')"
$sql_result mysql_query($sql,$connection) or die ("Could not connect to database test");  
} else { echo 
"Wrong file type<br>\n"; exit; } 

?> 
<script language="JavaScript"> 
opener.location.reload(); 
self.close(); 
</script>


any help is greatly appreciated.
cheers aron.

Reply With Quote
  #2  
Old October 24th, 2004, 12:06 PM
aron aron is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: brisbane
Posts: 42 aron User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 9 m 35 sec
Reputation Power: 5
any one.

anyone able to help.


Quote:
Originally Posted by aron
Hi All, i have made this script already using imagemagic, but have just relised the server runs gd librarys, i know this script works in image magic (i have used it elsewhere) was wondering if somone could help me convert it to use gd please.

PHP Code:
//Image Magick 
$rndnum rand(10,999999); 
exec("C:\imagemagick\convert.exe -resize 800 ".$new_file." ".$path.$rndnum.$id."minus_01".".jpg"); 
exec("C:\imagemagick\convert.exe -resize 420 ".$new_file." ".$path.$rndnum.$id."minus_02".".jpg"); 
exec("C:\imagemagick\convert.exe -resize 105 ".$new_file." ".$path.$rndnum.$id."minus_03".".jpg"); 
exec("C:\imagemagick\convert.exe -resize 72 ".$new_file." ".$path.$rndnum.$id."minus_04".".jpg"); 
$dbsave $rndnum.$id
//print "<br>Thumbnail: ".$path."thumb".$rndnum.".jpg"; 

//deletes original image 
unlink($new_file); 


thats the image magic resize bit.

if you need the entire script here it is.

PHP Code:
<? 
//header('Refresh: 2; URL="register_test.php'); 
$path "C:/path to image upload folder/"
//define("C_FILEPATH", "C:/path to image upload folder/"); 
$max_size 1048576
$id $_GET['id']; 
//chmod($path, 0777); 

if (!isset($HTTP_POST_FILES['userfile'])) die ("No image selected.");  

if  (
is_uploaded_file($HTTP_POST_FILES['userfile']['tm
p_name'
])) { 

if (
$HTTP_POST_FILES['userfile']['size']>$max_size) { die("The file is too big<br>\n"); } 
if ((
$HTTP_POST_FILES['userfile']['type']=="image/gif") || ($HTTP_POST_FILES['userfile']['type']=="image/pjpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/jpeg")) { 

if (
file_exists($path $HTTP_POST_FILES['userfile']['name'])) { die("The file already exists<br>\n");} 
$tmp_file $HTTP_POST_FILES['userfile']['tmp_name']; 
$new_file $path.$HTTP_POST_FILES['userfile']['name']; 

$res copy($tmp_file,$new_file); 

if (!isset(
$res)) { die("Upload Failed!<br>"); } 
echo 
"Upload Sucessful<br>Redirecting back to Your Details.<br>\n"

echo 
"File Name: ".$path.$HTTP_POST_FILES['userfile']['name']."<br>\n"
echo 
"File Size: ".$HTTP_POST_FILES['userfile']['size']." bytes<br>\n"
echo 
"File Type: ".$HTTP_POST_FILES['userfile']['type']."<br>\n"

//Image Magick 
$rndnum rand(10,999999); 
exec("C:\imagemagick\convert.exe -resize 800 ".$new_file." ".$path.$rndnum.$id."minus_01".".jpg"); 
exec("C:\imagemagick\convert.exe -resize 420 ".$new_file." ".$path.$rndnum.$id."minus_02".".jpg"); 
exec("C:\imagemagick\convert.exe -resize 105 ".$new_file." ".$path.$rndnum.$id."minus_03".".jpg"); 
exec("C:\imagemagick\convert.exe -resize 72 ".$new_file." ".$path.$rndnum.$id."minus_04".".jpg"); 
$dbsave $rndnum.$id
//print "<br>Thumbnail: ".$path."thumb".$rndnum.".jpg"; 

//deletes original image 
unlink($new_file); 

//insert images into database 
$connection mysql_connect("server","usernmae","password") or die('Could not connect to the database server');  
$db mysql_select_db("database"$connection) or die ("Unable to select database.");  
$sql "INSERT into images (listing_id,url) values('$id', '$dbsave')"
$sql_result mysql_query($sql,$connection) or die ("Could not connect to database test");  
} else { echo 
"Wrong file type<br>\n"; exit; } 

?> 
<script language="JavaScript"> 
opener.location.reload(); 
self.close(); 
</script>


any help is greatly appreciated.
cheers aron.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > help with converting image resize script from image magic to gd


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT