Help with PHP

Ermitgilsukaru

Registered
I don't really know if this is the right place to post this, but here goes.

I am trying to build a site with PHP. It contains picture galleries and should automate the creation of thumbnails. I was going to use Image Magick to make a scaled copy of every incoming picture. The problem is I don't know how to do it through PHP.

I tried to use exec() like this:

PHP:
exec("mogrify -geometry 120x120 /foo/bar.jpg"); //Where mogrify is a Image Magick command and /foo/bar.jpg was the path to the image

But nothing happened. No error messages of any kind or anything like that, the image simply had not been changed. I then tried to use exec() with a return variable and printing it out, like this:

PHP:
exec("mogrify -geometry 120x120 /foo/bar.jpg" $return_variable);

echo $return_variable;

When I ran the script with these lines the image stayed unchanged as before but printed out "127".

My questions are these:

Why does the script return "127"?
Is there any other way to execute shell commands in PHP?
How else could I make thumbnails in PHP?
Oh, and also where is the php.ini file located in Mac OS X?
 
I'm not familiar with Image Magick, but about php, there are a few other ways of executing external commands. goto www.php.net and search for 'exec'. You should see exec, system, passthru, etc. As well, depending on your PHP system, you may be able to use the Image Functions. Also, if mogrify returns the altered image on STDOUT, and since exec returns the last line of the command's output, check to see what you get by running that command alone in a shell environment. If you have Marc Liyange's distribution of PHP, there is no php.ini. On his site, he tells you how to make the php.ini file. And finally, you could just display the imaes themselves, and set the image tag to 200x200 with the width and height properties (though this would seriously suck for large pics).
 
Originally posted by hsotncam
...you may be able to use the Image Functions...
How do I know if the OS X version of Apache + PHP have the Image Functions turned on?

I can't make any of them work and I can't find the php.ini file (the Apple distribution must be like the Marc Liyange one you mentioned) or any useful info in phoinfo().

Do we have these functions or not?
 
Go get CompletePHP4.
If you're gonna host it on a different server than the OSX machine you're developing it on, that will obviously need the same functions you use.
 
Does that mean these functions are NOT there?

Will Apple be upgrading PHP to 4.3 as part of OS 10.3 Panther?

I'd rather be patient and wait for the out-of-box version and avoid a customer install that will certainly break when upgrading...
 
Thanks for the pointer to CompletePHP4!

I just peeked at it. I have a working stable configuration and I'm a bit paranoid to do what looks like a complete reinstall.

Also it seems to need Apache 2.x... I need to stick with Apache 1.3.x for various reasons.

I think I'll wait for Panther...
 
Incidentally at the top of this thread your code example does NOT have a comma between the argument and $return_variable, which is required.
 
On an update to this. Try www.entropy.ch for the PHP/MySQL packages, they're the uptodate packages like those from ServerLogistics, but they require a little tinkering in config files, but the upside is they work with the apple instal of apache. :D
 
Damn it!

I now have Panther (which includes PHP 4.3.2) and this still DOES NOT WORK!

I thought the necessary GD lib & image function stuff was all bundled within PHP >= 4.3.x?


Grrrrrrrrrrrrrrrrrr.
 
This:
Code:
<?php
var_dump(gd_info());
?>
...produces this:
Code:
Fatal error: Call to undefined function: gd_info() in <clip>gd_checker.php on line 2
 
http://www.php.net/manual/en/ref.image.php said:
RJ-Gerry at wiu dot edu
07-Mar-2003 12:00
I have successfully installed GD and FreeType 2 with PHP 4.3.0 on my OS X 10.2.4 (Jaguar) machine. Using fink http://fink.sourceforge.net which comes with dselect (a menu – based apt-get), I was able to download and install both GD and FreeType 2 without having to compile either one of them. I was then able to add them into PHP by using this configure command (and then make and make install of course):

./configure --with-mysql --with-apxs --with-gd=/sw --with-freetype-dir=/sw --with-ttf

The directories for gd and freetype were both /sw because that is where fink installs its software. I also added the –-with-ttf to make sure that True Type Fonts were supported. Hope this helps any OS X users!
Anyone know what RJ-Gerry at wiu dot edu is trying to say here?

Where is he running this ./configure command?

Even if I could compile this, where do I configure PHP? There is no php.ini that I can find...
 
Back
Top