# Help with PHP



## Ermitgilsukaru (Oct 25, 2002)

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:


```
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:


```
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?


----------



## hsotncam (Oct 26, 2002)

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).


----------



## TommyWillB (Sep 6, 2003)

> _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?


----------



## Pengu (Sep 7, 2003)

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.


----------



## TommyWillB (Sep 7, 2003)

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...


----------



## TommyWillB (Sep 7, 2003)

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...


----------



## michaelsanford (Oct 5, 2003)

Incidentally at the top of this thread your code example does NOT have a comma between the argument and $return_variable, which is required.


----------



## Pengu (Oct 6, 2003)

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.


----------



## TommyWillB (Nov 2, 2003)

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.


----------



## rhg (Nov 2, 2003)

Try to provide the complete path to mogrify in the exec() command.


----------



## TommyWillB (Nov 2, 2003)

This:
	
	



```
<?php
var_dump(gd_info());
?>
```
...produces this:
	
	



```
Fatal error: Call to undefined function: gd_info() in <clip>gd_checker.php on line 2
```


----------



## TommyWillB (Nov 2, 2003)

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):
> 
> ...


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...


----------

