1

私は2つの画像を持っています。私はそれを操作するための.shファイルを作成しました。まず、そのために for ループを使用します。

私のディレクター構造: -

test image doc newimage angelimage test.sh 5elements10.png Boltonclinics5.png

今、私は2つの画像を3rd.pngの両方で合成し、newimageに保存した後、 newimageフォルダー内の画像を特定の天使に変換したい. だから私はコードで試します

   #!/bin/bash
for f in $( ls *.png ); do
  composite -gravity center $f ./doc/back.png ./newimage/new$f
done 
for f in `ls ./newimage`; do

  convert $f -rotate -7 ./angelimage/ang$f
done

今、私は for ループが適切に動作することを発見しましたが、2番目のループは次のようなエラーを出します

convert: unable to open image `new-5elements10.png':  @ error/blob.c/OpenBlob/2587.
convert: unable to open file `new-5elements10.png' @ error/png.c/ReadPNGImage/3234.
convert: missing an image filename `new-5elements10.png' @ error/convert.c/ConvertImageCommand/3011.
convert: unable to open image `new-boltonclinics5.png':  @ error/blob.c/OpenBlob/2587.
convert: unable to open file `new-boltonclinics5.png' @ error/png.c/ReadPNGImage/3234.
convert: missing an image filename `new-boltonclinics5.png' @ error/convert.c/ConvertImageCommand/3011.
4

1 に答える 1

-1

コマンドに供給されるファイルのリストを作成するためにls(1)を使用しないでください。単純なグロブ拡張で十分です(以下に示すように)。

空白の問題を防ぐために変数を引用してください。

コードに他の論理エラーがない場合、これは機能するはずです。

#!/bin/bash

for f in *.png;
do
    composite -gravity center "$f" ./doc/back.png "./newimage/new${f}"
done 

for f in ./newimage/*;
do
    convert -rotate -7 "$f" "./angelimage/ang$(basename "$f")"
done
于 2012-06-14T10:40:01.250 に答える