2017-04-05 93 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