We can't get it to work

A plethora of command-line scripts that perform geometric transforms, blurs, sharpens, edging, noise removal, and color manipulations.
Express
Posts: 3
Joined: 2014-12-15T13:04:16-07:00
Authentication code: 6789

We can't get it to work

Post by Express » 2014-12-15T13:22:04-07:00

Hi Fred or someone else who maybe knows.

We are trying to get your scripts working on hosting provider Servage.
We know imagemagick works but can't get your scripts to work. We try to get 3d text working.
Does some know if they work at all there ?

Thanks in advance,

Express

User avatar
fmw42
Posts: 25392
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: We can't get it to work

Post by fmw42 » 2014-12-15T14:31:12-07:00

I do not know anything about your ISP Servage. Are you trying to run the script using PHP exec(). If so, then review my pointer about running and modifying the script under PHP on my home page. Be sure to find out where IM convert resides in the directory structure of you host and put that into the script or in your .profile file. First thing to check is can your convert an image using PHP exec() with IM

exec("convert logo: logo.jpg");

If that does not work, then you need to find the path to convert, since it is not in your $PATH.

Even if the above works, the script needs to know where IM convert resides. That is why you need to put that in your $PATH via the pointers on my home page. That is often the issue. If you get that working and have modified the script as per my Pointers, then let me know what error messages you are getting and your exact command line


<?php
exec("3Dtext ... arguments ... result.jpg",$out,$returnval);
foreach($out as $text)
{echo "$text<br>";}
?>

If you are not using PHP exec() or the terminal, then please clarify your exact situation. Also please identify the version of IM that you are using and your platform. My scripts do not work on Windows unless with Cygwin.

npz
Posts: 8
Joined: 2015-01-18T07:06:20-07:00
Authentication code: 6789

Re: We can't get it to work

Post by npz » 2015-01-18T07:08:40-07:00

I'm working together with Express and tried the following:

Code: Select all

<?
system('which convert',$path); 
echo '<hr/>';

$file[0]='logo.jpg';
exec("convert logo: ".$file[0]);
echo '<img src="'.$file[0].'?'.time().'"/>';
echo '<hr/>';

$file[1]="3Dtext";
echo $file[1]." permissions: ".substr(sprintf('%o', fileperms($file[1])), -4);
echo '<hr/>';
exec($file[1].' -h', $out);
print_r($out);

exec($file[1].' -t "Testtext" result.jpg',$out,$returnval);
print_r($out);
print_r($returnval);
?>
http://live.danichelle.com/fred_forum_reply_test_2.php

User avatar
fmw42
Posts: 25392
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: We can't get it to work

Post by fmw42 » 2015-01-18T12:20:37-07:00

I can try to help.

What version of Imagemagick and what platform are you using?

Did you locate where IM resides and if so where is that (appears to be /usr/bin)? Did you put that into your PATH environment variable in the script or in your .profile file. These are all Pointers on my home page for use with PHP -- please read them. See my link below. Did you edit the file as described there including changing the dir="." to dir="/tmp"? Did you change permissions via chmod u+x or chmod 777?

I recommend also putting my scripts into some directory and putting that into your PATH or .profile file. Then you can run the script from anywhere; otherwise, you need to put the path to where the script is located if not your current directory.

Please give me your exact command line without all your PHP code and variables. Take one example from my web site and put it into

<?php
exec("3Dtext ... arguments ... input output 2>&1",$out,$returnval);
foreach($out as $text)
{echo "$text<br>";}
?>

In the above, use texteffect or texteffect.sh just as name as the script when you downloaded it. Or make them both the same.


Run that from wherever you have put the script.

What messages do you get?

npz
Posts: 8
Joined: 2015-01-18T07:06:20-07:00
Authentication code: 6789

Re: We can't get it to work

Post by npz » 2015-01-19T06:50:02-07:00

Many thanks for the help Fred!

Version: ImageMagick 6.7.8-7 2013-01-11 Q16 http://www.imagemagick.org Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC Features: OpenMP
OS: Linux node2 2.100.4-1-amd64-grsec #1 SMP Tue Dec 28 21:57:50 CET 2010 x86_64
PHP version: 5.2.42-servage30

Did you locate where IM resides and if so where is that (appears to be /usr/bin)?
- Yes, it's in /usr/bin (/usr/bin/convert)

Did you put that into your PATH environment variable in the script or in your .profile file?
- Yes, I put it into the 3Dtext script

These are all Pointers on my home page for use with PHP -- please read them. See my link below.
- Read all of them and followed them up.

Did you edit the file as described there including changing the dir="." to dir="/tmp"?
- Yes

Did you change permissions via chmod u+x or chmod 777?
- Yes

This doesn't return anything unfortunately:

Code: Select all

<?php
exec('3Dtext -t "Testtext" result.jpg 2>&1',$out,$returnval);
foreach($out as $text)
{echo "$text<br>";}
?>

snibgo
Posts: 12002
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: We can't get it to work

Post by snibgo » 2015-01-19T09:20:56-07:00

Fred's scripts are wonderful but quite complex. As it doesn't seem to work, I suggest you try first with trivial scripts, for example:

1. a script that echoes "hello world"
2. a script that echoes "hello world", then "convert logo: logo.png", then echoes "finished".

When those work, sprinkle fred's script with echoes to find where (if at all) it is failing.
snibgo's IM pages: im.snibgo.com

npz
Posts: 8
Joined: 2015-01-18T07:06:20-07:00
Authentication code: 6789

Re: We can't get it to work

Post by npz » 2015-01-19T09:54:17-07:00


snibgo
Posts: 12002
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: We can't get it to work

Post by snibgo » 2015-01-19T10:48:25-07:00

Good. At the start of Fred's script, insert a line "echo 3dtext start". At the end, but before exit, insert the line "echo 3dtext end". When you run this with PHP, does this text show? If so, then the script is completing as it should, but perhaps the eval is failing.

If only "3dtext start" shows but not the end, then the script is failing. More echoes will show where.

You should also try running the script from the command line, with the same arguments.
snibgo's IM pages: im.snibgo.com

User avatar
fmw42
Posts: 25392
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: We can't get it to work

Post by fmw42 » 2015-01-19T11:09:34-07:00

Send me your modified script to fmw at alink dot net

In the mean time, try a simpler script such as 2colorthresh and then autolabel. Do they both work?

If neither work, then if you can, run them from the command line and see if that works.

Snibgo's suggestion of adding echo command throughout the script, is how I debug them. Put echo "X" where X = 1,2,3.... in sequence throughout the script between command lines and let me know where it stops. Or if you cannot do that, I can send you a version back once you send me your modified script.

It may be an issue with the use of eval in PHP, so running it in the command line may be a good test. But the echo numbers will surely help to identify that if it fails at the number before the final command with the eval. Be sure to put one at the top and bottom of the script (just before the final exit 0).

Be sure you have the freetype delegate built into your IM version.

What do you get from

convert -list configure

at the line starting with DELEGATES? Does it include freetype?

npz
Posts: 8
Joined: 2015-01-18T07:06:20-07:00
Authentication code: 6789

Re: We can't get it to work

Post by npz » 2015-01-19T13:11:40-07:00

Tried both 2colortresh and autolabel but they don't work.

Currently I don't have access to the command line. @Express: can you try this?

I debugged everything, the code doesn't die/exit. It just doesn't seem to do anyhing.

I executed "convert -list configure" with PHP: http://live.danichelle.com/debug.php
It does include freetype

I'll email you the scripts

User avatar
fmw42
Posts: 25392
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: We can't get it to work

Post by fmw42 » 2015-01-19T13:54:37-07:00

See my direct email to you for some revisions.

npz
Posts: 8
Joined: 2015-01-18T07:06:20-07:00
Authentication code: 6789

Re: We can't get it to work

Post by npz » 2015-01-19T14:07:19-07:00

Thanks again Fred. It doesn't return anything. Might have to do with Servage's security settings of exec() / shell_exec() then...

npz
Posts: 8
Joined: 2015-01-18T07:06:20-07:00
Authentication code: 6789

Re: We can't get it to work

Post by npz » 2015-01-19T14:34:55-07:00

We're using PHP Version 5.2.42. From PHP Version 5.4 safe mode is deprecated. We just deactivated the safe mode, it's pending.

User avatar
fmw42
Posts: 25392
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: We can't get it to work

Post by fmw42 » 2015-01-19T15:21:22-07:00

Yes, it would appear to be something with your hosting providers setup with PHP. Some providers do not allow exec(). But then why were you able to do convert logo: logo.jpg in an exec command in your PHP. So I am totally puzzled why you get no resulting messages with the script that has all the echo statements. You should be seeing each one when you run the PHP script. Did you run my version of the PHP file as well as my version of the 2colorthresh script?

Can you run the 2colorthresh script on a local computer in a bash shell terminal?

npz
Posts: 8
Joined: 2015-01-18T07:06:20-07:00
Authentication code: 6789

Re: We can't get it to work

Post by npz » 2015-01-20T00:23:14-07:00

Disabling safe_mode did the job: http://live.danichelle.com/2colorthresh.php

I take it that 'convert' is more like a native Magick function and the custom scripts aren't.

It echoes all values. I think the next step is to remove the 'bash' part?

Post Reply