[英]ImageMagick unix shell script doesn't work when fired with php shell_exec()
我必须使用Fred的ImageMagick脚本创建一个图像转换序列,特别是fx过渡 。
在我的PHP代码中,我调整了所有标准大小的图像,然后我将所有这些图片重命名为pic000001.jpg,pic000002.jpg,pic000003.jpg等等(我用$ count计算),然后我做:
$frameIndex=0;
$frames=18;
//for all the pic000001.jpg, pic000002.jpg, pic000003.jpg.... do a transition
//between them
for($seq=1;$seq<$count;$seq++){
//here I take a picture and the next(IE pic000001 and pic000002)
echo shell_exec("fxtransitions -e swirl -f $frames -d 20 -p 50 $path/pic".str_pad($seq, 6, '0', STR_PAD_LEFT).".jpg $path/pic".str_pad(($seq+1), 6, '0', STR_PAD_LEFT).".jpg $path/fx%06d.jpg");
//here I rename the temporany frames called
//fx000000.jpg to fx000035.jpg for each transition
//to a common index
for($c=0;$c<($frames*2);$c++){
rename("fx".str_pad($c, 6, '0', STR_PAD_LEFT).".jpg" ,str_pad($frameIndex, 6, '0', STR_PAD_LEFT).".jpg");
$frameIndex++;
}
}
然后,我使用FFMpeg组合所有帧并制作视频。 问题是fxtransition表示错误:
--- FILE DOES NOT EXIST OR IS NOT AN ORDINARY FILE, NOT READABLE OR HAS ZERO SIZE ---
(这是脚本肯定生成的消息),后跟这样的消息:
Warning: rename(fx000000.jpg,000000.jpg): No such file or directory in /var/www/html/TEST/APP/generateVideo.php on line 168
因为没有生成图片(它显示编号框架的算法是正确的,所以不要专注于那个)。
如果我打开服务器上的终端,使用ssh连接并运行该命令,它会给我同样的错误,除非我使用sudo。 如果我在php shell_exec上使用sudo,它将不会执行。 shell_exec('whoami')返回apache,apache是我参与这些函数的所有文件夹和文件的所有者。
有些帮助吗? 如果您有fred的imagemagick脚本的替代方案来生成过渡帧以生成视频,那么也将不胜感激。
我在使用Fred的ImageMagick脚本时遇到了这个问题。 解决方案是使用您喜欢的编辑器(vim,nano等)更新脚本文件(scriptname.sh)并设置正确的临时目录。 见下文:
# set directory for temporary files
dir="." # suggestions are dir="." or dir="/tmp"
#
在我的情况下,temp directoy是“/ tmp”
# set directory for temporary files
dir="/tmp" # suggestions are dir="." or dir="/tmp"
#
当我使用Fred的ImageMagick脚本中的textcleaner时,我遇到了这个问题。 解决方法是使用正确的路径tmp目录路径
在我的情况下
dir =“/ var / www / html / textcleaner / images /”#advice is dir =“。” 或者dir =“/ tmp”#
这应该是可写的
textcleaner.sh也将移动到该项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.