Unrotate script

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
Thomisback

Unrotate script

Post by Thomisback »

Hi,

I don't know a lot about imagemagick but what I'm basicly trying to do is unrotate a picture using this script:
http://www.fmwconcepts.com/imagemagick/ ... /index.php
by running it in a .PHP file.

So let's say
- I save the unrotate script as unrotate.sh
- I have got a picture saved as "picture.jpg"
- I create a PHP file with the following code:

Code: Select all

<?PHP
$output = shell_exec('bash ./unrotate.sh -f 40 picture.jpg picture_new.jpg');
echo "<pre>$output</pre>";
?>
But when I then try to run my PHP script it returns me the following error:

Code: Select all

--- FILE picture.jpg DOES NOT EXIST OR IS NOT AN ORDINARY FILE, NOT READABLE OR HAS ZERO SIZE ---
While the file does exist and is readable....

Any suggestions?
Thanks a lot.
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Unrotate script

Post by el_supremo »

That message is coming from Fred's script.
I presume that you have picture.jpg in the same directory as the unrotate.sh script, if not then that's the problem.

If you do then you could try to execute the command that is failing in Fred's script. See if this command gives you any errors or warnings:

Code: Select all

convert -quiet -regard-warnings picture.jpg +repage junk.jpg
Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
Thomisback

Re: Unrotate script

Post by Thomisback »

Hi,

Thanks for your reply, everything is in the same folder and I just tried executing your code by doing this:

Code: Select all

<?PHP
$output = shell_exec('convert -quiet -regard-warnings picture.jpg +repage junk.jpg');
echo "<pre>$output</pre>";
?>
and also like this:

Code: Select all

<?PHP
$cmd="convert -quiet -regard-warnings picture.jpg +repage junk.jpg";
system($cmd);
?>
Which doesn't return anything... just a blank page.
Anyone knows why?
Thanks a lot & kind regards
Thomisback

Re: Unrotate script

Post by Thomisback »

Oh I just tried to run this code I posted above on my local PC and that seemed to work and actually created a file called junk.jpg. No further error messages though. But when I try to execute the same piece of code on my web hosting it does not create a picture?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Unrotate script

Post by fmw42 »

Thomisback wrote:Hi,

Thanks for your reply, everything is in the same folder and I just tried executing your code by doing this:

Code: Select all

<?PHP
$output = shell_exec('convert -quiet -regard-warnings picture.jpg +repage junk.jpg');
echo "<pre>$output</pre>";
?>
and also like this:

Code: Select all

<?PHP
$cmd="convert -quiet -regard-warnings picture.jpg +repage junk.jpg";
system($cmd);
?>
Which doesn't return anything... just a blank page.
Anyone knows why?
Thanks a lot & kind regards


You probably need to provide the full path to convert, something like, /usr/local/bin/convert, or where ever your provider has put IM.
Thomisback

Re: Unrotate script

Post by Thomisback »

Hi, thanks for your reply.

I looked up the location where IM is located and my hosting website's FAQ states:

Code: Select all

The convert path to ImageMagick, version 6 on our servers is:
/usr/local/bin/
So I tried both:

Code: Select all

<?PHP
$cmd="/usr/local/bin/convert -quiet -regard-warnings picture.jpg +repage picture_new.jpg";
system($cmd);
?>
and:

Code: Select all

<?PHP
$output = shell_exec('/usr/local/bin/convert -quiet -regard-warnings picture.jpg +repage picture_new.jpg');
echo "<pre>$output</pre>";
?>
Still no picture is being created...
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Unrotate script

Post by fmw42 »

Thomisback wrote:Hi, thanks for your reply.

I looked up the location where IM is located and my hosting website's FAQ states:

Code: Select all

The convert path to ImageMagick, version 6 on our servers is:
/usr/local/bin/
So I tried both:

Code: Select all

<?PHP
$cmd="/usr/local/bin/convert -quiet -regard-warnings picture.jpg +repage picture_new.jpg";
system($cmd);
?>
and:

Code: Select all

<?PHP
$output = shell_exec('/usr/local/bin/convert -quiet -regard-warnings picture.jpg +repage picture_new.jpg');
echo "<pre>$output</pre>";
?>
Still no picture is being created...

get rid of the excess arguments and try just

/usr/local/bin/convert picture.jpg picture_new.jpg

Also see my private note to you about checking if you can actually access IM and get the version numbers back. Also look at the rubbleweb web site of Bonzo (see my private message also for that).

Fred
Thomisback

Re: Unrotate script

Post by Thomisback »

Hi thanks for your reply!

Code: Select all

<?php
$cmd="/usr/local/bin/convert picture.jpg picture_new.jpg";
system($cmd);
?>
Worked fine and created a file, I checked IM version and path and these are set correctly. I will try to figure it out from here (But suggestions are welcome!).
Thanks a lot.
Post Reply