我已经做了一整天了。我正在尝试将图片上传到Mediawiki,但当ImageMagick尝试创建缩略图时出现了以下错误:
Error creating thumbnail: convert: no decode delegate for this image format `/tmp/magick-11924QG1rRXzT948I' @ error/constitute.c/ReadImage/552.
convert: no images defined `/tmp/s3thumb-cripEh' @ error/convert.c/ConvertImageCommand/3127.
我为Mediawiki设置了一个调试文件,以下是日志记录的内容:
BitmapHandler::doTransform: creating 112x120 thumbnail at /tmp/s3thumb-cripEh using scaler im
BitmapHandler::doTransform: called wfMkdirParents(/tmp)
BitmapHandler::getMagickVersion: Running convert -version
wfShellExec: /bin/bash '/var/www/mediawiki-1.21.2/includes/limit.sh' ''\''/usr/local/bin/convert'\'' -version' 'MW_CPU_LIMIT=180; MW_CGROUP='\'''\''; MW_MEM_LIMIT=202400; MW_FILE_SIZE_LIMIT=102400; MW_WALL_CLOCK_LIMIT=180'
BitmapHandler::transformImageMagick: running ImageMagick: '/usr/local/bin/convert' -quality 80 -background white -define jpeg:size=112x120 '' -thumbnail '112x120!' -depth 8 -sharpen '0x0.4' -rotate -0 '/tmp/s3thumb-cripEh' 2>&1
wfShellExec: /bin/bash '/var/www/mediawiki-1.21.2/includes/limit.sh' 'OMP_NUM_THREADS='\''1'\'' '\''/usr/local/bin/convert'\'' -quality 80 -background white -define jpeg:size=112x120 '\'''\'' -thumbnail '\''112x120!'\'' -depth 8 -sharpen '\''0x0.4'\'' -rotate -0 '\''/tmp/s3thumb-cripEh'\'' 2>&1' 'MW_CPU_LIMIT=180; MW_CGROUP='\'''\''; MW_MEM_LIMIT=202400; MW_FILE_SIZE_LIMIT=102400; MW_WALL_CLOCK_LIMIT=180'
[thumbnail] thumbnail failed on ip-10-168-26-167: error 1 "convert: no decode delegate for this image format `/tmp/magick-11924QG1rRXzT948I' @ error/constitute.c/ReadImage/552.
convert: no images defined `/tmp/s3thumb-cripEh' @ error/convert.c/ConvertImageCommand/3127." from "'/usr/local/bin/convert' -quality 80 -background white -define jpeg:size=112x120 '' -thumbnail '112x120!' -depth 8 -sharpen '0x0.4' -rotate -0 '/tmp/s3thumb-cripEh' 2>&1"
LocalS3File::transform thumb:
LocalS3File::transform thumbTempPath: /tmp/s3thumb-cripEh, dest: wiki-images/thumb/1/19/5ovrDaU.jpg/112px-5ovrDaU.jpg
info:1
LocalS3File::transform return thumb: MediaTransformError Object
(
[htmlMsg] => Error creating thumbnail: convert: no decode delegate for this image format `/tmp/magick-11924QG1rRXzT948I' @ error/constitute.c/ReadImage/552.<br />
convert: no images defined `/tmp/s3thumb-cripEh' @ error/convert.c/ConvertImageCommand/3127.<br />
[textMsg] => Error creating thumbnail: convert: no decode delegate for this image format `/tmp/magick-11924QG1rRXzT948I' @ error/constitute.c/ReadImage/552.<br />
convert: no images defined `/tmp/s3thumb-cripEh' @ error/convert.c/ConvertImageCommand/3127.<br />
[width] => 112
[height] => 120
[url] =>
[path] =>
[file] =>
[page] =>
[responsiveUrls] => Array
(
)
[storagePath:protected] =>
)
尝试通过命令行进行操作,从日志中复制了命令(但使用了测试文件):
convert -quality 80 -background white -define jpeg:size=112x120 '' -thumbnail '112x120!' -depth 8 -sharpen '0x0.4' -rotate -0 'logo.jpg
'
但是这个过程卡住了。如果我运行:
sudo convert logo.png -quality 80 -background white -define jpeg:size=112x120 -thumbnail '112x120!' -depth 8 -sharpen '0x0.4' -rotate -0 logo.jpg
它有效。
如果我检查DELEGATES,我有:
DELEGATES jng jp2 jpeg png ps tiff xml zlib
我尝试将MediaWiki的默认内存增加到
$wgMaxShellMemory = 202400;
我感觉我已经尝试了所有方法。有什么想法吗?
编辑: 目前我已经发现以下内容:
我相信shell没有执行ImageMagick命令,因为在其中的反斜杠被转义了。
wfShellExec: /bin/bash '/var/www/mediawiki-1.21.2/includes/limit.sh' ''\''/usr/local/bin/convert'\'' -version' 'MW_CPU_LIMIT=180; MW_CGROUP='\'''\''; MW_MEM_LIMIT=202400; MW_FILE_SIZE_LIMIT=102400; MW_WALL_CLOCK_LIMIT=180'
那些
''\''
导致命令无法运行,因此出现了"no decode"
错误。它无法解码,因为文件不存在。我已经追踪到wfShellEec
在GlobalFunctions.php
中。在我的文件中,wfShellExec
函数大约位于第2778行。在
if ( php_uname( 's' ) == 'Linux' )
块中,有以下内容:escapeshellarg( $cmd )
我移除了escapeshellarg()
函数,只留下了$cmd
。
再次尝试上传,错误消失了,文件被创建,但现在缩略图文件大小为0字节。
有任何想法吗?