我整天都在这。我正在尝试将图像上传到 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 jng jp2 jpeg png ps tiff xml zlib
我尝试将媒体 wiki 上的默认内存增加到
$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 字节。
有任何想法吗?