473,396 Members | 2,016 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ImageMagick probz in PHP

Hi there,

Just a little problem I guess... I have stripped out just an imageresize
string for ImageMagic in a php-file:

<?
exec('convert -quality 100 -antialias -sample 100x100
/var/www/html/aftermath2.jpg /var/www/html/thumb_aftermath.jpg');
?>

The string would work in a shell, but not using the above php-file. Any
idea's?

Greetz,

Roger
Jul 16 '05 #1
9 3807
uws
I <bf**********@news3.tilbu1.nb.home.nl>, Roger Godefroy skrev:
Just a little problem I guess... I have stripped out just an imageresize
string for ImageMagic in a php-file:
<?
exec('convert -quality 100 -antialias -sample 100x100
/var/www/html/aftermath2.jpg /var/www/html/thumb_aftermath.jpg');
?>
The string would work in a shell, but not using the above php-file. Any
idea's?


Do you have write permission in the given directory?

mvrgr, Wouter

--
:wq mail uw*@xs4all.nl

don't just call me pessimist :: try and read between the lines -- tool
Jul 16 '05 #2
CHMODded the folder and files allready to 777. But no result... Any other
ideas? On another server it works however perfectly using the script
(without resize):

<?php
exec("convert -quality 100 aftermath2.jpg thumb_aftermath.jpg");
?>

But on this new server it won't ??? Strange isn't it?

"uws" <uw*@xs4all.invalid> schreef in bericht
news:yo*****************************************@k likmans.nl...
I <bf**********@news3.tilbu1.nb.home.nl>, Roger Godefroy skrev:
Just a little problem I guess... I have stripped out just an imageresize
string for ImageMagic in a php-file:
<?
exec('convert -quality 100 -antialias -sample 100x100
/var/www/html/aftermath2.jpg /var/www/html/thumb_aftermath.jpg');
?>
The string would work in a shell, but not using the above php-file. Any
idea's?
Do you have write permission in the given directory?

mvrgr, Wouter

--
:wq mail

uw*@xs4all.nl
don't just call me pessimist :: try and read between the lines --

tool
Jul 16 '05 #3

Roger Godefroy wrote:
Just a little problem I guess... I have stripped out just an imageresize
string for ImageMagic in a php-file:

<?
exec('convert -quality 100 -antialias -sample 100x100
/var/www/html/aftermath2.jpg /var/www/html/thumb_aftermath.jpg');
?>

The string would work in a shell, but not using the above php-file. Any
idea's?


When you tried it in the shell, did you use the exact same file in the exact
same directory?
Do you get any error messages (use -debug and -log)? Just some
guesses/suggestions:

Are you 100% certain the path is correct (did you blindly copy path from old
server)?
Is the original file at least 100x100?
Try 'convert /var/www/html/aftermath2.jpg
/var/www/html/thumb_aftermath.jpg'. That'll at least confirm it's not the
sample, quality or antialias.
Make sure /var/www/html/thumb_aftermath.jpg doesn't exist (could have
trouble replacing).
If you have SSH or Telnet access to the server, try just running the
command.
Try with a different image type. I had a helluva time with PNGs - IM was
configured wrong.

Shawn
--
Shawn Wilson
sh***@glassgiant.com
http://www.glassgiant.com
Jul 16 '05 #4
> > Just a little problem I guess... I have stripped out just an
imageresize string for ImageMagic in a php-file: <? exec('convert -quality 100 -antialias -sample 100x100 /var/www/html/aftermath2.jpg /var/www/html/thumb_aftermath.jpg'); ?> The string would work in a shell, but not using the above php-file. Any idea's?
When you tried it in the shell, did you use the exact same file in the exact same directory?
Yupz... in the same folder as the php-script and jpg-file using the exact
string as in the php-file.
Do you get any error messages (use -debug and -log)? Just some guesses/suggestions: Are you 100% certain the path is correct (did you blindly copy path from old server)?
Also without the path it would work on the "old" server. On the new server,
it wouldn't work with the full path /var/www/html or just the filename.
Is the original file at least 100x100?
Original file is 1600x1200
Try 'convert /var/www/html/aftermath2.jpg /var/www/html/thumb_aftermath.jpg'. That'll at least confirm it's not the sample, quality or antialias.
Also no output. However executing in a shell, it would...
Make sure /var/www/html/thumb_aftermath.jpg doesn't exist (could have trouble replacing).
File not existing...
If you have SSH or Telnet access to the server, try just running the command. Try with a different image type. I had a helluva time with PNGs - IM was configured wrong.


Also when testing with a .gif, no result... :(

Any other ideas?

Greetings,

Roger Godefroy
Jul 16 '05 #5


Roger Godefroy wrote:
Just a little problem I guess... I have stripped out just an imageresize string for ImageMagic in a php-file: <? exec('convert -quality 100 -antialias -sample 100x100 /var/www/html/aftermath2.jpg /var/www/html/thumb_aftermath.jpg'); ?> The string would work in a shell, but not using the above php-file. Any idea's?


When you tried it in the shell, did you use the exact same file in the

exact same directory?


Yupz... in the same folder as the php-script and jpg-file using the exact
string as in the php-file.
Do you get any error messages (use -debug and -log)? Just some

guesses/suggestions:


Are you 100% certain the path is correct (did you blindly copy path

from old server)?


Also without the path it would work on the "old" server. On the new server,
it wouldn't work with the full path /var/www/html or just the filename.
Is the original file at least 100x100?


Original file is 1600x1200
Try 'convert /var/www/html/aftermath2.jpg

/var/www/html/thumb_aftermath.jpg'. That'll at least confirm it's not

the sample, quality or antialias.


Also no output. However executing in a shell, it would...
Make sure /var/www/html/thumb_aftermath.jpg doesn't exist (could have

trouble replacing).


File not existing...
If you have SSH or Telnet access to the server, try just running the

command. Try with a different image type. I had a helluva time with

PNGs - IM was configured wrong.


Also when testing with a .gif, no result... :(


Hmmm...

Did you try the log?

Maybe try something simple, like
passthru("ls -l /var/www/html/");

If you get a list of stuff in that directory, try passthru with your convert
command...

Maybe this is on the right track:
From PHP.net (exec function)
Note that when in 'Safe Mode' you must have the script or program you are
trying to execute in the 'safe_mode_exec_dir'. You can find out what this
directory is by using phpinfo().

HTH,
Shawn

--
Shawn Wilson
sh***@glassgiant.com
http://www.glassgiant.com
Jul 16 '05 #6
Hi,

I got a result using the ls-command. But not using the convert-command. The
server isn't in safe mode (checked using phpinfo()). I just got the server
error-log:

----[ SNAP ]----

[2003-07-24 15:56:12]: info: (real/target/actual) uid: (admin7/admin/admin)
gid:

(admin7/admin/admin) cmd: php-script alt_doc_root:
/home/virtual/site7/fst/var/

www chroot: 1

[2003-07-24 15:56:28]: info: (real/target/actual) uid: (admin7/admin/admin)
gid:

(admin7/admin/admin) cmd: php-script alt_doc_root:
/home/virtual/site7/fst/var/

www chroot: 1

[2003-07-24 15:59:59]: info: (real/target/actual) uid: (admin7/admin/admin)
gid:

(admin7/admin/admin) cmd: php-script alt_doc_root:
/home/virtual/site7/fst/var/

www chroot: 1

[2003-07-24 16:00:16]: info: (real/target/actual) uid: (admin7/admin/admin)
gid:

(admin7/admin/admin) cmd: php-script alt_doc_root:
/home/virtual/site7/fst/var/

www chroot: 1

[2003-07-24 16:02:48]: info: (real/target/actual) uid: (admin7/admin/admin)
gid:

(admin7/admin/admin) cmd: php-script alt_doc_root:
/home/virtual/site7/fst/var/

www chroot: 1

[2003-07-24 16:06:06]: info: (real/target/actual) uid: (admin7/admin/admin)
gid:

(admin7/admin/admin) cmd: php-script alt_doc_root:
/home/virtual/site7/fst/var/

www chroot: 1

[2003-07-24 16:06:12]: info: (real/target/actual) uid: (admin7/admin/admin)
gid:

(admin7/admin/admin) cmd: php-script alt_doc_root:
/home/virtual/site7/fst/var/

www chroot: 1

[2003-07-24 16:10:22]: info: (real/target/actual) uid: (admin7/admin/admin)
gid:

(admin7/admin/admin) cmd: php-script alt_doc_root:
/home/virtual/site7/fst/var/

www chroot: 1

----[/SNAP]----

Any idea?
Greetings,

Roger

"Shawn Wilson" <sh***@glassgiant.com> schreef in bericht
news:3F***************@glassgiant.com...


Roger Godefroy wrote:
> Just a little problem I guess... I have stripped out just an
> imageresize string for ImageMagic in a php-file:

>

> <?

> exec('convert -quality 100 -antialias -sample 100x100

> /var/www/html/aftermath2.jpg /var/www/html/thumb_aftermath.jpg');

> ?>

>

> The string would work in a shell, but not using the above php-file.

> Any idea's?


When you tried it in the shell, did you use the exact same file in the

exact same directory?


Yupz... in the same folder as the php-script and jpg-file using the exact string as in the php-file.
Do you get any error messages (use -debug and -log)? Just some

guesses/suggestions:


Are you 100% certain the path is correct (did you blindly copy path

from old server)?


Also without the path it would work on the "old" server. On the new server, it wouldn't work with the full path /var/www/html or just the filename.
Is the original file at least 100x100?


Original file is 1600x1200
Try 'convert /var/www/html/aftermath2.jpg

/var/www/html/thumb_aftermath.jpg'. That'll at least confirm it's not

the sample, quality or antialias.


Also no output. However executing in a shell, it would...
Make sure /var/www/html/thumb_aftermath.jpg doesn't exist (could have

trouble replacing).


File not existing...
If you have SSH or Telnet access to the server, try just running the

command. Try with a different image type. I had a helluva time with

PNGs - IM was configured wrong.


Also when testing with a .gif, no result... :(


Hmmm...

Did you try the log?

Maybe try something simple, like
passthru("ls -l /var/www/html/");

If you get a list of stuff in that directory, try passthru with your

convert command...

Maybe this is on the right track:
From PHP.net (exec function)
Note that when in 'Safe Mode' you must have the script or program you are
trying to execute in the 'safe_mode_exec_dir'. You can find out what this
directory is by using phpinfo().

HTH,
Shawn

--
Shawn Wilson
sh***@glassgiant.com
http://www.glassgiant.com

Jul 16 '05 #7
I would get an error on the header() row (Internal Server Error 500).

The paths are also without result...

Maybe a server-error?

Greetz...
"Shawn Wilson" <sh***@glassgiant.com> schreef in bericht
news:3F***************@glassgiant.com...
Roger Godefroy wrote:
Hi,

I got a result using the ls-command. But not using the convert-command. The server isn't in safe mode (checked using phpinfo()). I just got the server error-log:

----[ SNAP ]----

[2003-07-24 15:56:12]: info: (real/target/actual) uid: (admin7/admin/admin) gid:

(admin7/admin/admin) cmd: php-script alt_doc_root:
/home/virtual/site7/fst/var/

www chroot: 1

[2003-07-24 15:56:28]: info: (real/target/actual) uid: (admin7/admin/admin) gid:

(admin7/admin/admin) cmd: php-script alt_doc_root:
/home/virtual/site7/fst/var/

www chroot: 1

[2003-07-24 15:59:59]: info: (real/target/actual) uid: (admin7/admin/admin) gid:

(admin7/admin/admin) cmd: php-script alt_doc_root:
/home/virtual/site7/fst/var/

www chroot: 1

[2003-07-24 16:00:16]: info: (real/target/actual) uid: (admin7/admin/admin) gid:

(admin7/admin/admin) cmd: php-script alt_doc_root:
/home/virtual/site7/fst/var/

www chroot: 1

[2003-07-24 16:02:48]: info: (real/target/actual) uid: (admin7/admin/admin) gid:

(admin7/admin/admin) cmd: php-script alt_doc_root:
/home/virtual/site7/fst/var/

www chroot: 1

[2003-07-24 16:06:06]: info: (real/target/actual) uid: (admin7/admin/admin) gid:

(admin7/admin/admin) cmd: php-script alt_doc_root:
/home/virtual/site7/fst/var/

www chroot: 1

[2003-07-24 16:06:12]: info: (real/target/actual) uid: (admin7/admin/admin) gid:

(admin7/admin/admin) cmd: php-script alt_doc_root:
/home/virtual/site7/fst/var/

www chroot: 1

[2003-07-24 16:10:22]: info: (real/target/actual) uid: (admin7/admin/admin) gid:

(admin7/admin/admin) cmd: php-script alt_doc_root:
/home/virtual/site7/fst/var/

www chroot: 1

----[/SNAP]----

Any idea?

Greetings,

Roger

"Shawn Wilson" <sh***@glassgiant.com> schreef in bericht
news:3F***************@glassgiant.com...


Roger Godefroy wrote:

> > > Just a little problem I guess... I have stripped out just an
>
> > > imageresize string for ImageMagic in a php-file:
>
> > >
>
> > > <?
>
> > > exec('convert -quality 100 -antialias -sample 100x100
>
> > > /var/www/html/aftermath2.jpg /var/www/html/thumb_aftermath.jpg'); >
> > > ?>
>
> > >
>
> > > The string would work in a shell, but not using the above php-file. >
> > > Any idea's?
>
> >
>
> > When you tried it in the shell, did you use the exact same file in the >
> > exact same directory?
>
> Yupz... in the same folder as the php-script and jpg-file using the exact
> string as in the php-file.
>
> > Do you get any error messages (use -debug and -log)? Just some
>
> > guesses/suggestions:
>
> >
>
> > Are you 100% certain the path is correct (did you blindly copy path >
> > from old server)?
>
> Also without the path it would work on the "old" server. On the new

server,
> it wouldn't work with the full path /var/www/html or just the filename. >
> > Is the original file at least 100x100?
>
> Original file is 1600x1200
>
> > Try 'convert /var/www/html/aftermath2.jpg
>
> > /var/www/html/thumb_aftermath.jpg'. That'll at least confirm it's not >
> > the sample, quality or antialias.
>
> Also no output. However executing in a shell, it would...
>
> > Make sure /var/www/html/thumb_aftermath.jpg doesn't exist (could have >
> > trouble replacing).
>
> File not existing...
>
> > If you have SSH or Telnet access to the server, try just running the >
> > command. Try with a different image type. I had a helluva time with >
> > PNGs - IM was configured wrong.
>
> Also when testing with a .gif, no result... :(

Hmmm...

Did you try the log?

Maybe try something simple, like
passthru("ls -l /var/www/html/");

If you get a list of stuff in that directory, try passthru with your

convert
command...

Maybe this is on the right track:
From PHP.net (exec function)
Note that when in 'Safe Mode' you must have the script or program you are trying to execute in the 'safe_mode_exec_dir'. You can find out what this directory is by using phpinfo().


This is a tough one.

Maybe try
/home/virtual/site7/fst/var/www/html/aftermath2.jpg
/home/virtual/site7/fst/var/www/html/thumb_aftermath.jpg
as your paths.

Or try this and only this in a file (make sure there's no spaces or enters
before or after the <?PHP and ?>!!!):

<?PHP
header("image/jpg");
$cmd = "convert xc:#000000 -resize '500x150!' -gravity 'Center' -pointsize

'64' -fill '#000099' -draw 'text -4,-16 \"Hello World\"' jpg:-";
passthru($cmd);
?>

Or it might be header("image/jpeg"); I'm not sure if it matters... You should get a JPG on your browser. If this works, it'll tell you that the problem is likely with your image paths...

Shawn
--
Shawn Wilson
sh***@glassgiant.com
http://www.glassgiant.com

Jul 16 '05 #8
> > > This is a tough one.

Maybe try
/home/virtual/site7/fst/var/www/html/aftermath2.jpg
/home/virtual/site7/fst/var/www/html/thumb_aftermath.jpg
as your paths.

Or try this and only this in a file (make sure there's no spaces or enters before or after the <?PHP and ?>!!!):

<?PHP
header("image/jpg");
$cmd = "convert xc:#000000 -resize '500x150!' -gravity
'Center' -pointsize '64'
-fill '#000099' -draw 'text -4,-16 \"Hello World\"' jpg:-";
passthru($cmd);
?>

Or it might be header("image/jpeg"); I'm not sure if it matters...
You should
get a JPG on your browser. If this works, it'll tell you that the
problem is
likely with your image paths...


I'm an idiot. The header line should be:

header("Content-type: image/jpg");
or
header("Content-type: image/jpeg");

My apologies...


The headers works fine now, however with a standard not-found-image (red
cross) on the screen. So again no result :(
Jul 16 '05 #9
On Thu, 24 Jul 2003 13:59:59 +0200, "Roger Godefroy" <godefroy@(no
spam)home.nl> wrote:
Just a little problem I guess... I have stripped out just an imageresize
string for ImageMagic in a php-file:

<?
exec('convert -quality 100 -antialias -sample 100x100
/var/www/html/aftermath2.jpg /var/www/html/thumb_aftermath.jpg');
?>
http://uk.php.net/manual/en/function.exec.php

exec has the facility to give you the return code back; use it and post the
value, it may give a clue.
The string would work in a shell, but not using the above php-file. Any
idea's?


Your webserver runs in potentially entirely different environment from your
shell.

Is convert on your webserver's PATH? If not, use a full path to convert (do
this anyway).

Does the webserver user have permissions to read and write the files?

Does the webserver user have permissions to execute convert?

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 16 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Randell D. | last post by:
Folks, I've not used ImageMagick before - I've worked with the gd functions that are pre-compiled in PHP and found some of the limits problematic yet heard better reviews on ImageMagick. I've...
3
by: Joe | last post by:
Hey I have tried to install ImageMagick on my server, but my apache stalls when i try to start it with the following line added to my php.ini file: extension=php_imagick.dll I can't even...
5
by: nawfer | last post by:
for to resize and copy original photos into a new directory and to use for a thumbnail gallery on the web; what is better: GD, Netpbm or imagemagick and why? very thank
1
by: shanergb | last post by:
Hi all. I'm creating a web-based application that uses PHP, MySQL & Apache on a Windows platform. What I need to do is create images on the fly with either GD or ImageMagick, display them on the...
3
by: Chuck Anderson | last post by:
I am trying to use ImageMagick from a Php script running under Windows XP. I have installed the latest version of ImageMagick - 6.2.1-7 and even tried backing up to version 5.5.7 (based on a...
5
by: Jim Red | last post by:
Hello Can someone give me an example how to use the Imagemagick - Identity command? Cheers Jim
6
by: eholz1 | last post by:
Hello Users, I am not sure if this is the place to post an imagemagick question - please advise. I have imagemagick 6.3 installed, runs from command line ok, etc. I have tried (several times...
2
by: azrael | last post by:
Hy did anyone manage to work with imahemagick through python. I've been googling like a crazy for some instalation instructions, but i cant find anything. please help. thnx
0
by: empiresolutions | last post by:
I am working with a TIF to JPG conversion that will result in the JPG being printed from a web page. My issue is the final JPG image prints VERY blurry. The TIF file that has the following...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.