Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > creating thumbnails w/ php and netpbm

creating thumbnails w/ php and netpbm
Thread Tools
Registered User
Join Date: Jul 2003
Location: San Jose
Status: Offline
Reply With Quote
Jan 18, 2004, 07:12 PM
 
so i've written my image upload script which works just fine, but for some reason, i'm having trouble creating the thumbnails. as it stands right now, the script will create the thumbnail file, but it is an empty file (0 k) - so it creates the file but writes no data to it.

if anyone can shed some light as to what i'm missing, i would appreciate it.

thanks...

[php]<? if (!$_POST["submit"]) { ?>
<html>

<head></head>

<body>

<form action="<? echo $PHP_SELF; ?>" method="post" name="form" enctype="multipart/form-data">
<input type="file" name="img" />
<input type="submit" name="submit" value="upload" />
</form>

</body>

</html>
<?

} else {

$dir = "/gallery/albums/";
$file = $dir . $_FILES["img"]["name"];
$thumb = $dir . "th_" . $_FILES["img"]["name"];
$netpbm = "/gallery/netpbm/";
$new_w = 200;
$new_h = 200;

$topnm = "jpegtopnm";
$tothumb = "ppmtojpeg";

if ($_FILES["img"]["type"] == "image/jpeg")
{
move_uploaded_file($_FILES["img"]["tmp_name"], $file);

$cmd = $netpbm . $topnm . " \"" . $file . "\" | ";
$cmd .= $netpbm . "pnmscale -xysize " . $new_w . " " . $new_h . " | ";
$cmd .= $netpbm . $tothumb . " > \"" . $thumb . "\"";

exec($cmd);
}
else
{
echo "not a jpg";
}

}

?>[/php]
     
   
Thread Tools
Forum Links
Forum 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
Top
Privacy Policy
All times are GMT -5. The time now is 12:52 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2