convert only work with full path

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
ditto
Posts: 27
Joined: 2012-10-12T10:23:43-07:00
Authentication code: 67789

convert only work with full path

Post by ditto »

I really need som help here. I have a CentOS 7 server wich everything works correct on. But on my CentOS 6 server I have a problem that convert only works in shell and not in a php script.

I have upgraded to ImageMagick 7.0.3-0 and imagick 3.4.3RC1 , I am running PHP 5.6.26 and mod_ruid2

This code work in my webpages:

Code: Select all

<?php
echo "<pre>";
system("/usr/local/bin/convert logo: logo.gif");
echo "</pre>";
?>
However this code does not work and give a blank page:

Code: Select all

<?php
echo "<pre>";
system("which convert");
echo "</pre>";
?>
Also the last code give this error in apache error log: "no convert in /sbin:/usr/sbin:/bin:/usr/bin"

However if I run the PHP code from shell, it does work, it is only in webapges that it does not work. In order for it to work in webpages, I am forced to use the full path in the command. I have reinstalled many times and been struggling for a couple of days already. Strange thing is that it works correct on my CentOS 7 server, only in CentOS 6 server it does not work.

I have installed both imagemagick and imagick from source. Here is more output from my problem server:

Code: Select all

# php -i | grep imagick
imagick
imagick module => enabled
imagick module version => 3.4.3RC1
imagick classes => Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator, ImagickKernel
imagick.locale_fix => 0 => 0
imagick.progress_monitor => 0 => 0
imagick.skip_version_check => 0 => 0

Code: Select all

identify -version
Version: ImageMagick 7.0.3-0 Q16 x86_64 2016-09-19 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP
Delegates (built-in): bzlib freetype jpeg tiff x zlib

Code: Select all

# echo "$PATH"
/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/dell/srvadmin/bin:/opt/dell/srvadmin/sbin:/root/bin

Code: Select all

# which convert
/usr/local/bin/convert

Code: Select all

# /usr/local/bin/identify -list configure

Path: /usr/local/lib/ImageMagick-7.0.3//config-Q16HDRI/configure.xml

Name           Value
-------------------------------------------------------------------------------
CC             gcc -std=gnu99 -std=gnu99
CFLAGS         -I/usr/include/freetype2      -fopenmp -g -O2 -Wall -mtune=core2 -fexceptions -pthread -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16
CODER_PATH     /usr/local/lib/ImageMagick-7.0.3/modules-Q16HDRI/coders
CONFIGURE      ./configure  '--with-perl=/usr/bin/perl'
CONFIGURE_PATH /usr/local/etc/ImageMagick-7/
COPYRIGHT      Copyright (C) 1999-2016 ImageMagick Studio LLC
CPPFLAGS       -I/usr/local/include/ImageMagick-7
CXX            g++
CXXFLAGS       -g -O2 -pthread
DEFS           -DHAVE_CONFIG_H
DELEGATES      bzlib mpeg freetype jpeg ps tiff x zlib
DISTCHECK_CONFIG_FLAGS  --disable-deprecated  --with-quantum-depth=16  --with-jemalloc=no  --with-umem=no  --with-autotrace=no  --with-gslib=no  --with-fontpath=  --with-rsvg=no  --with-perl=/usr/bin/perl
DOCUMENTATION_PATH /usr/local/share/doc/ImageMagick-7
EXEC-PREFIX    /usr/local
EXECUTABLE_PATH /usr/local/bin
FEATURES       DPC HDRI Cipher OpenMP
FILTER_PATH    /usr/local/lib/ImageMagick-7.0.3/modules-Q16HDRI/filters
GIT_REVISION   11197
HOST           x86_64-unknown-linux-gnu
INCLUDE_PATH   /usr/local/include/ImageMagick-7
LDFLAGS        -L/usr/local/lib
LIB_VERSION    0x703
LIB_VERSION_NUMBER 7,0,3,0
LIBRARY_PATH   /usr/local/lib/ImageMagick-7.0.3
LIBS              -ltiff -lfreetype    -ljpeg             -lXext -lXt   -lSM -lICE -lX11   -lbz2       -lz    -lm -lgomp
NAME           ImageMagick
PCFLAGS        -fopenmp -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16
PREFIX         /usr/local
QuantumDepth   16
RELEASE_DATE   2016-09-19
SHARE_PATH     /usr/local/share/ImageMagick-7
SHAREARCH_PATH /usr/local/lib/ImageMagick-7.0.3/config-Q16HDRI
TARGET_CPU     x86_64
TARGET_OS      linux-gnu
TARGET_VENDOR  unknown
VERSION        7.0.3
WEBSITE        http://www.imagemagick.org

Path: [built-in]

Name           Value
-------------------------------------------------------------------------------
FEATURES       OpenMP
NAME           ImageMagick
QuantumDepth   16
It has worked correct on this server before, but I don't know what time it stopped working in PHP without full path, as I might not have tested that when I upgraded the last time.

Is there something wrong with my system PATH variable? Hope someone can help out here. Thanks!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: convert only work with full path

Post by snibgo »

I don't use PHP or Unix, but it seems that a solution would be to install IM to /bin or somewhere that PHP searches. Alternatively, tell PHP where to find convert: add this directory to php.ini or somewhere.
snibgo's IM pages: im.snibgo.com
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: convert only work with full path

Post by Bonzo »

An alternative workaround would be to have a file containing:

Code: Select all

$path = 'usr/local/bin/convert';
Then include that file in all your pages using Imagemagick then use:

Code: Select all

<?php
echo "<pre>";
system("$path logo: logo.gif");
echo "</pre>";
?>
I have just noticed you are using version 7 and you should be using magick not convert anyway. I found that convert does not work on version 7 unless I use magick convert
ditto
Posts: 27
Joined: 2012-10-12T10:23:43-07:00
Authentication code: 67789

Re: convert only work with full path

Post by ditto »

Thanks. But because there are many different users and developers on the server, I would really like to fix the actual problem with my setup.
ditto
Posts: 27
Joined: 2012-10-12T10:23:43-07:00
Authentication code: 67789

Re: convert only work with full path

Post by ditto »

Regading the version: I do not have any problem using convert om my centos 7 server running 7.0.3-0

Also I have tested 6.9.5-9, and have the same problem.

I have a problem with path, wich make it only work with full path in php sites, but on shell and php in shell, it works without full path.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert only work with full path

Post by fmw42 »

I do not think Imagick works with IM 7
ditto
Posts: 27
Joined: 2012-10-12T10:23:43-07:00
Authentication code: 67789

Re: convert only work with full path

Post by ditto »

Sure it does: https://pecl.php.net/package-changelog. ... e=3.4.3RC1

Also I have a server with centos 7 (like I already posted), that work just fine with IM 7 amd imagick 3.4.3RC1

The problem server is centos 6, and I think I have a problem with path. I would be thankfull for any help pointing me in the right direction.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert only work with full path

Post by fmw42 »

I stand corrected.
Post Reply