Connecting Tech Pros Worldwide Help | Site Map

php and images

Martin Herrman
Guest
 
Posts: n/a
#1: Jul 17 '05
Hi all,

I'm writing a module for a Content Management System called 'Site@School'
(siteatschool.sf.net). One of it's requirements is that if any other
software package is used, it must be invisible to the user.

Now I need to resize jpeg and gif images. When I use php extensions like
imagick.so or the gd-lib one, I cannot include them into the module. The
user that installs the module (which can be a school on their ISP's
webspace) must also install the extensions and adapt the sytem's php.ini
file (which is impossible if you don't have root access).

I know recent php versions can be compiled with the --enable-gd option,
but I'm not allowed to make that assumption (maybe an ISP doesn't want it
to enable because of possible security problems for example).

Do you know any solution to this problem? (it should be possible, although
not trivial, to compile and install a package in ones homedirectory)

much thanks in advance,

Martin
Jason
Guest
 
Posts: n/a
#2: Jul 17 '05

re: php and images


"Martin Herrman" <m.herrman@student.tue.nl> wrote in message
news:pan.2003.10.09.15.19.22.461323@student.tue.nl ...[color=blue]
> Hi all,
>
> I'm writing a module for a Content Management System called 'Site@School'
> (siteatschool.sf.net). One of it's requirements is that if any other
> software package is used, it must be invisible to the user.
>
> Now I need to resize jpeg and gif images. When I use php extensions like
> imagick.so or the gd-lib one, I cannot include them into the module. The
> user that installs the module (which can be a school on their ISP's
> webspace) must also install the extensions and adapt the sytem's php.ini
> file (which is impossible if you don't have root access).
>
> I know recent php versions can be compiled with the --enable-gd option,
> but I'm not allowed to make that assumption (maybe an ISP doesn't want it
> to enable because of possible security problems for example).
>
> Do you know any solution to this problem? (it should be possible, although
> not trivial, to compile and install a package in ones homedirectory)
>
> much thanks in advance,
>
> Martin
>[/color]

Run imagemagick from the command line instead of using an extension.


Martin Herrman
Guest
 
Posts: n/a
#3: Jul 17 '05

re: php and images


On Thu, 09 Oct 2003 18:04:16 +0000, Jason wrote:
[color=blue]
> Run imagemagick from the command line instead of using an extension.[/color]

it's so simple :-)

Thanks!

Martin
Justin Koivisto
Guest
 
Posts: n/a
#4: Jul 17 '05

re: php and images


Jason wrote:
[color=blue]
> "Martin Herrman" <m.herrman@student.tue.nl> wrote in message
> news:pan.2003.10.09.15.19.22.461323@student.tue.nl ...
>[color=green]
>>Hi all,
>>
>>I'm writing a module for a Content Management System called 'Site@School'
>>(siteatschool.sf.net). One of it's requirements is that if any other
>>software package is used, it must be invisible to the user.
>>
>>Now I need to resize jpeg and gif images. When I use php extensions like
>>imagick.so or the gd-lib one, I cannot include them into the module. The
>>user that installs the module (which can be a school on their ISP's
>>webspace) must also install the extensions and adapt the sytem's php.ini
>>file (which is impossible if you don't have root access).
>>
>>I know recent php versions can be compiled with the --enable-gd option,
>>but I'm not allowed to make that assumption (maybe an ISP doesn't want it
>>to enable because of possible security problems for example).
>>
>>Do you know any solution to this problem? (it should be possible, although
>>not trivial, to compile and install a package in ones homedirectory)
>>
>>much thanks in advance,
>>
>>Martin[/color]
>
> Run imagemagick from the command line instead of using an extension.[/color]

Actually, the way I do it is to first see if GD is compiled in. Since I
only use jpeg or png images, I check for functions that relate to those
image types.

if($image_type=='jpeg' && !function_exists('imagecreatefromjpeg'){
// GD is not installed with jpeg support, use image magick
}else if($image_type=='jpeg'){
// use GD to resize the image
}else if($image_type=='png' && !function_exists('imagecreatefrompng'){
// GD is not installed with pngsupport, use image magick
}else if($image_type=='png'){
// use GD to resize the image
}

This way, if GD is installed, you can simply use it. On the other hand,
if you need to use imagemagick (from the command line), you need to know
where on the server it is installed. Sometimes this is as trivial as
doing a $im_convert=system('which convert'); However, if IM isn't in the
path, then you'd have to specify where it is on the system.

HTH

--
Justin Koivisto - spam@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.

Closed Thread