2017-04-05 95 views
0

我正在使用此命令来压扁文件夹中的3个图像。Image magick convert忽略一些图像

for pos1 in 1*.png; do for pos3 in 3*.png; do for pos6 in 6*.png; do convert -gravity center $pos1 $pos3 $pos6 -layers flatten $pos1$pos3$pos6 ;done ;done ;done 

这是我的文件夹的样子:

enter image description here

出于某种原因,ImageMagick的忽略1*.png图像,制成的只是$pos3$pos6组成。这种行为的原因是什么?如何解决?我操纵的图像是一些较老的图像魔术操纵的产物。

UPDATE:

经过一些测试,它看起来像该错误来自一个事实,即输入图像的到来之前的转换/复合命令的输出(记不起我用哪一个)。不过,我不知道如何解决这个问题。

识别命令输出(无直方图):

Format: PNG (Portable Network Graphics) 
    Mime type: image/png 
    Class: DirectClass 
    Geometry: 3843x3402+0+0 
    Units: Undefined 
    Type: TrueColorAlpha 
    Endianess: Undefined 
    Colorspace: sRGB 
    Depth: 8-bit 
    Channel depth: 
    red: 8-bit 
    green: 8-bit 
    blue: 8-bit 
    alpha: 1-bit 
    Channel statistics: 
    Pixels: 13073886 
    Red: 
     min: 0 (0) 
     max: 255 (1) 
     mean: 246.072 (0.96499) 
     standard deviation: 44.204 (0.173349) 
     kurtosis: 23.2206 
     skewness: -4.96363 
     entropy: 0.0669139 
    Green: 
     min: 0 (0) 
     max: 255 (1) 
     mean: 246.072 (0.96499) 
     standard deviation: 44.2038 (0.173348) 
     kurtosis: 23.2205 
     skewness: -4.96362 
     entropy: 0.0669169 
    Blue: 
     min: 0 (0) 
     max: 255 (1) 
     mean: 246.072 (0.96499) 
     standard deviation: 44.2038 (0.173348) 
     kurtosis: 23.2207 
     skewness: -4.96364 
     entropy: 0.066917 
    Alpha: 
     min: 255 (1) 
     max: 255 (1) 
     mean: 255 (1) 
     standard deviation: 0 (0) 
     kurtosis: 0 
     skewness: 0 
     entropy: 0 
    Image statistics: 
    Overall: 
     min: 0 (0) 
     max: 255 (1) 
     mean: 184.554 (0.723742) 
     standard deviation: 38.2817 (0.150124) 
     kurtosis: 150.659 
     skewness: -25.8099 
     entropy: 0.050187 
    Rendering intent: Perceptual 
    Gamma: 0.45455 
    Chromaticity: 
    red primary: (0.64,0.33) 
    green primary: (0.3,0.6) 
    blue primary: (0.15,0.06) 
    white point: (0.3127,0.329) 
    Background color: white 
    Border color: srgba(223,223,223,1) 
    Matte color: grey74 
    Transparent color: none 
    Interlace: None 
    Intensity: Undefined 
    Compose: Over 
    Page geometry: 3843x3402+0+0 
    Dispose: Undefined 
    Iterations: 0 
    Compression: Zip 
    Orientation: Undefined 
    Properties: 
    date:create: 2017-04-05T20:18:59+02:00 
    date:modify: 2017-04-05T10:36:08+02:00 
    png:bKGD: chunk was found (see Background color, above) 
    png:cHRM: chunk was found (see Chromaticity, above) 
    png:gAMA: gamma=0.45454544 (See Gamma, above) 
    png:IHDR.bit-depth-orig: 8 
    png:IHDR.bit_depth: 8 
    png:IHDR.color-type-orig: 6 
    png:IHDR.color_type: 6 (RGBA) 
    png:IHDR.interlace_method: 0 (Not interlaced) 
    png:IHDR.width,height: 3843, 3402 
    png:sRGB: intent=0 (Perceptual Intent) 
    png:text: 2 tEXt/zTXt/iTXt chunks were found 
    png:tIME: 2017-04-03T18:20:37Z 
    signature: ea0ce8b483b92bda18d999d203a5e1329d48fb63059d6702051b74f7930286fc 
    Artifacts: 
    filename: /Users/mainuser/Desktop/final/HALFS/to/1_1ND1_1.png 
    verbose: true 
    Tainted: False 
    Filesize: 710KB 
    Number pixels: 13.07M 
    Pixels per second: 54.47MB 
    User time: 0.230u 
    Elapsed time: 0:01.240 
    Version: ImageMagick 6.9.7-3 Q16 x86_64 2017-01-07 http://www.imagemagick.org 
+0

我的答案是否解决了您的问题?如果是这样,请考虑接受它作为您的答案 - 通过点击投票计数旁边的空心绿色勾号/复选标记。如果没有,请说出什么不起作用,以便我或其他人可以进一步帮助您。谢谢。 http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work/5235#5235 –

+0

这是评论,所以我不确定.. – sanjihan

回答

1

更新回答

当我们有一些问题,你不能分享您的图像,让我们做一些我们自己的:

convert -size 600x200 xc:none -fill red -draw "circle 100,100 100,200" -bordercolor black -border 1 1.png 

enter image description here

convert -size 600x200 xc:none -fill lime -draw "circle 300,100 400,100" -bordercolor black -border 1 2.png 

enter image description here

convert -size 600x200 xc:none -fill blue -draw "circle 500,100 600,100" -bordercolor black -border 1 3.png 

enter image description here

现在让我们来展平,然后在一个透明的背景:

convert [123].png -background none -flatten result.png 

enter image description here

也许你可以创建这些图像,并与您的版本试试ImageMagick的。

原来的答案

这取决于你的文件是如何在规模和透明度方面,但试试这个在你的循环中:

convert -gravity center "$pos1" "$pos3" -composite "$pos6" -composite "${pos1}${pos3}${pos6}.png" 

这假定“$ POS1”是像素尺寸方面最大的文件。

请注意,在扩展它们时应始终使用双引号shell变量,以防文件名中有空格。

+0

图像大小约3500x3500,全部大小相同,且大多透明。我尝试了上面的建议,但结果是一样的。它只是不会重叠它们... – sanjihan

+0

order:$ pos3 $ pos6 $ pos1 - > output is just $ pos1 – sanjihan

+0

order:$ pos3 $ pos1 $ pos6 - > output只是$ pos1和$ pos6 – sanjihan