exec() and netpbm probs
Posted: Fri Jan 24, 2003 11:41 am
I'm trying to code a simple image resizing function using the netpbm tools. (I wish I could use GD, but in this instance, I cannot.) Netpbm works fine from the command line but I'm getting odd output when I use it from within PHP.
I'll quote the code below, but essentially this is the situation. I'm using netpbm to transform jpeg to pnm, scale the pnm, then transform back to jpeg. When I run the commands through PHP using exec() (or system()) the correct files are created, but they are 0k files and so unusable. (www has permission to write to the directory.)
However, when I echo the exact commands into the browser, then copy those and paste them into the command line, it works perfectly.
Here's the code. Both of the filenames are absolute references.
If it didn't work at all, I'd be less puzzled than what's happening. Any suggestions would be greatly appreciated.
Apache/1.3.26, PHP 4.1.2, OS X 10.2.3, Netpbm 9.25
-tinfoilgrrl
I'll quote the code below, but essentially this is the situation. I'm using netpbm to transform jpeg to pnm, scale the pnm, then transform back to jpeg. When I run the commands through PHP using exec() (or system()) the correct files are created, but they are 0k files and so unusable. (www has permission to write to the directory.)
However, when I echo the exact commands into the browser, then copy those and paste them into the command line, it works perfectly.
Here's the code. Both of the filenames are absolute references.
Code: Select all
<?php
$command = 'jpegtopnm ' . $image . ' > ' . IMAGE_DIR . $name . '.ppm';
exec($command);
$command = 'pnmscale -width=' . $max_width . ' ' . IMAGE_DIR . $name . '.ppm' . ' > ' . IMAGE_DIR . '1_' . $name . '.ppm';
exec($command);
$command = 'pnmtojpeg ' . IMAGE_DIR . '1_' . $name . '.ppm' . ' > ' . IMAGE_DIR . $name;
exec($command);
?>Apache/1.3.26, PHP 4.1.2, OS X 10.2.3, Netpbm 9.25
-tinfoilgrrl