Page 1 of 1

problem with exec,php,IM

Posted: 2014-02-28T23:08:43-07:00
by Arash11
hi , im tring to convert some jpg files
and i put a.jpg into the script folder


my code is :

Code: Select all

putenv("MAGICK_THREAD_LIMIT=1");
putenv("PATH=/usr/local/bin:/usr/bin:/bin");
exec("/usr/bin/convert  -debug exception  '".__DIR__."/a.jpg"."'  '".__DIR__."/b.jpg"."' 2>&1",$array);			
echo "<br>".print_r($array)."<br>";
it works fine with some jpgs file
but when i switch the jpg with new jpg file , convert is stop working
looks like it dose not work all kind of jpgs







above code work with this img :
Image

and stop working with this one :
Image

and output for bad jpg is :

Code: Select all

Array ( [0] => 2014-02-28T23:53:12-06:00 0:00.010 0.000u 6.7.1 Exception convert[625869]: xml-tree.c/ParseCloseTag/1358/Exception [1] => ParseError unexpected closing tag [2] => 2014-02-28T23:53:12-06:00 0:00.010 0.000u 6.7.1 Exception convert[625869]: xml-tree.c/ParseCloseTag/1358/Exception [3] => ParseError unexpected closing tag [4] => 2014-02-28T23:53:12-06:00 0:00.010 0.000u 6.7.1 Exception convert[625869]: xml-tree.c/ParseCloseTag/1358/Exception [5] => ParseError unexpected closing tag ) 
1
and my IM version is : Version: ImageMagick 6.7.1-7 2012-11-28 Q16 On sharing linux host

i search all over the google but i cannot find any help

Re: problem with exec,php,IM

Posted: 2014-03-01T02:58:30-07:00
by Bonzo
It converts OK for me on Windows; I would start with something simple and hardcode your data into the convert code to find if the problem is your image or your code:

Code: Select all

exec("/usr/bin/convert  -debug exception cat.jpg new_cat.jpg 2>&1",$array);         
echo "<br>".print_r($array)."<br>";
I have never used putenv("PATH=/usr/local/bin:/usr/bin:/bin"); but it does not seem to be of any use as you are defining the path to convert in your exec() command.

Re: problem with exec,php,IM

Posted: 2014-03-01T06:39:37-07:00
by Arash11
hi , thanks for your replay
i use every thing , but still no hope

Evan this code is not working :

Code: Select all

exec("/usr/bin/convert  '/home/go/public_html/yo/test/a.jpg' '/home/go/public_html/yo/test/b.jpg' 2>&1;",$array);			
every thing is ok , but for this jpgs , every query in exec stop working
i post an other querys its stop working

Code: Select all

exec("/usr/bin/convert  -colorspace RGB '".$CMS['gupload'].$ImgFileName.'.jpg'."' -resize 1000x1000\> '".$CMS['img'].'a/'.$ImgFileName.'.jpg'."' ");			

Code: Select all

exec("/usr/bin/convert '".$CMS['gupload'].$ImgFileName.'.jpg'."' -resize 486x486^  -gravity Center  -crop 486x120+0+0 '".$CMS['img'].'b/'.$ImgFileName.'.jpg'."' ");			


for this picture all the codes stop working:
Image

and for this picture all code works fine :
Image


every IM Query @ exec stop working for cat pic and tree pic , but flower pic and bicycle pic just fine , i don't know why !!!!!!!!!!
some body help me

Re: problem with exec,php,IM

Posted: 2014-03-01T09:46:56-07:00
by Bonzo
The common thing I see is the images with your watermark on are not working and the ones without work. That would lead me to suspect there is a problem with the program adding your watermark.

Try to run your code on an image before you add the watermark and after to see what happens.