2017-06-07 9 views
0

私はこのコードを実行するのに一日中努力していますが、チャンスはありません。画像上でGIMPフィルタを実行し、あとで特定のパスに保存したいと思います。このコードでは:C#のGIMPフィルター

string choosenFile = "D:\\here\\is\\the\\image"; 
string gimpFile = "D:\\here\\is\\my\\gimp exe"; 



void seamlessFilter() { 
    try { 
     if (!string.IsNullOrEmpty(choosenFile)) { 
      string a = @"-b ""(script-fu-tile \""" 
      + choosenFile 
      + "100 100 0 TRUE 70" 
      + @")"" -b ""(gimp-quit 0)"""; 
      string result = ExecuteCommandSync(a); 
      Texture2D newTex = loadImage (new Vector2(200, 200), Path.GetFullPath(choosenFile)); 
      newTex = null; 
     } else { 
      UnityEngine.Debug.Log("Please select a image"); 
     } 
    } catch (Exception ex){ 
     UnityEngine.Debug.Log (ex.ToString()); 
    } 
} 

public string ExecuteCommandSync(string command) { 
    ProcessStartInfo processStartInfo = new ProcessStartInfo (gimpFile, command); 
    processStartInfo.RedirectStandardOutput = true; 
    processStartInfo.UseShellExecute = false; 
    processStartInfo.CreateNoWindow = true; 

    Process process = new Process(); 
    process.StartInfo = processStartInfo; 

    process.Start(); 
    StreamReader reader = process.StandardOutput; 
    string result = reader.ReadToEnd(); 
    Console.WriteLine (result); 
    return result; 
} 

文字列を読み取ることができなかったことを、私はフィルタを実行しようと、私は毎回エラーが発生します。ここ は.scmです:

` 
(define (script-fu-tile img 
     drawable 
     blend-x 
     blend-y 
     overlap 
     square) 

(let* 

    (

    (sel-float1 0) 

    (sel-float2 0) 

    (sel-float3 0) 
    (sel-float4 0) 
    (high-pass-layer 0) 

    (yoffset 0) 

    (img-w (/ (car (gimp-image-width img)) 2)) 

    (img-h (/ (car (gimp-image-height img)) 2)) 

;(newimg (car (gimp-image-new (- (car (gimp-image-width img)) blend-x) 
(- (car (gimp-image-height img)) blend-y) RGB))) 

    ) 

    (if (= square 1) 

     (set! yoffset (+ (- (* (- img-w img-h) 2) (- blend-x blend-y)) overlap)) 

     (set! yoffset overlap) 

    ) 


    (gimp-undo-push-group-start img) 


    (gimp-rect-select img 0 0 img-w img-h CHANNEL-OP-REPLACE FALSE 0) 


    (gimp-edit-copy drawable) 

    (set! sel-float1 (car (gimp-edit-paste drawable FALSE))) 

    (gimp-floating-sel-to-layer sel-float1) 

    (gimp-layer-translate sel-float1 (- (- img-w blend-x) yoffset) (- (- img-h blend-y) overlap)) 


    (gimp-rect-select img img-w 0 img-w img-h CHANNEL-OP-REPLACE FALSE 0) 


    (gimp-edit-copy drawable) 

    (set! sel-float2 (car (gimp-edit-paste drawable FALSE))) 
    (gimp-floating-sel-to-layer sel-float2) 

    (gimp-layer-translate sel-float2 (- 0 img-w) (- (- img-h blend-y) overlap)) 


    (gimp-rect-select img 0 img-h img-w img-h CHANNEL-OP-REPLACE FALSE 0) 


    (gimp-edit-copy drawable) 

    (set! sel-float3 (car (gimp-edit-paste drawable FALSE))) 

    (gimp-floating-sel-to-layer sel-float3) 

    (gimp-layer-translate sel-float3 (- (- img-w blend-x) yoffset) (- 0 img-h)) 


    (gimp-rect-select img img-w img-h img-w img-h CHANNEL-OP-REPLACE FALSE 0) 


    (gimp-edit-copy drawable) 

    (set! sel-float4 (car (gimp-edit-paste drawable FALSE))) 

    (gimp-floating-sel-to-layer sel-float4) 

    (gimp-layer-translate sel-float4 (- 0 img-w) (- 0 img-h)) 


    (gimp-rect-select img (- 0 blend-x) (- 0 blend-x) (+ img-w (/ blend-x 2)) (+ img-h (+ blend-x blend-x)) CHANNEL-OP-REPLACE TRUE (/ blend-x 1.68)) 

    (gimp-selection-invert img) 

    (gimp-edit-clear sel-float4) 


    (gimp-rect-select img (- 0 blend-y) (- 0 blend-y) (+ img-w (+ blend-y blend-y)) (+ img-h (/ blend-y 2)) CHANNEL-OP-REPLACE TRUE (/ blend-y 1.68)) 

    (gimp-selection-invert img) 

    (gimp-edit-clear sel-float4) 


    (gimp-rect-select img (- (- img-w (- blend-x blend-y)) yoffset) (- 0 blend-y) (+ img-w (+ blend-y blend-y)) (+ img-h (/ blend-y 2)) CHANNEL-OP-REPLACE TRUE (/ blend-y 1.68)) 

    (gimp-selection-invert img) 

    (gimp-edit-clear sel-float3) 


    (gimp-rect-select img (- 0 blend-x) (- (- img-h (+ blend-x blend-y)) overlap) (+ img-w (/ blend-x 2)) (+ img-h (+ blend-x blend-x)) CHANNEL-OP-REPLACE TRUE (/ blend-x 1.68)) 

    (gimp-selection-invert img) 

    (gimp-edit-clear sel-float2) 


    (gimp-selection-none img) 


    ;(gimp-layer-delete drawable) 


    (gimp-image-crop img (- (- (* img-w 2) blend-x) yoffset) (- (- (* img-h 2) blend-y) overlap) 0 0) 





    ; Complete the undo group 

    (gimp-undo-push-group-end img) 


    ; Flush output 

    (gimp-displays-flush) 

) 
) 




(script-fu-register "script-fu-tile" 

    "<Image>/Filters/Map/Tileable..." 

    "Make seamless texture" 

    "Pavel aka RPG Roshchin <[email protected]>" 

    "Pavel aka RPG Roshchin" 

    "2011" 

    "RGB*, GRAY*" 

    SF-IMAGE "Image" 0 

    SF-DRAWABLE "Layer to blur" 0 

    SF-ADJUSTMENT "Blend x" '(100 0 1000 1 10 0 0) 

    SF-ADJUSTMENT "Blend y" '(100 0 1000 1 10 0 0) 

    SF-ADJUSTMENT "Overlap" '(0 0 1000 1 10 0 0) 

    SF-TOGGLE 
    "Make square texture" TRUE 

    ;SF-ADJUSTMENT "Homogenize brightness (%)" '(70 0 100 1 10 0 0) 

    )` 

誰が助けることができれば、私は絶望ので、私は、そう空き地になるだろう。ありがとうございました!たぶん

答えて

0

私はそれを自分で考え出しました。問題は、最初の引数imgはオブジェクトを期待していましたが、最初の引数として文字列を書きました。だから私は文字列としてオブジェクトをラップするために私のscmスクリプトを編集し、それはうまく動作します。

0

しかし、物事のルックスによって

はあなた試みる行くと見 hereを持っており、この方法を与える:

string a = @"gimp-2.6.exe -i -b ""(script-fu-tile \""" + 
       choosenFile + @"\""0 100 100 0 TRUE 70)"" -b ""(gimp-quit 0)"""; 

または:

string a = @"-b ""(script-fu-tile \""" 
     + choosenFile 
     + "100 100 0 TRUE 70" 
     + @")"" -b ""(gimp-quit 0)"""; 

がより次のようになります。本質的に:

string draw = "0"; 
    string blendx = "100"; 
    string blendy = "100"; 
    string overlap = "0"; 
    string sqrText = "TRUE"; 
    string adjBright = "70"; 
    string a = @"gimp-2.6.exe -i -b ""(simple-unsharp-mask \""" + 
       path + @"\"" " + draw + " " + blendx + " " + blendy + " " + overlap + " "+ sqrText + " " + adjBright + 
       @")"" -b ""(gimp-quit 0)"""; 

あなたのコードに上記の文字列に問題があるというエラーが表示されているかのように見えます。それらの少数の試みを与え、私にコメントしてください。

+0

私は既にこのチュートリアルでこのコードを行っています。 – Viktoria

+0

もう一度更新されました。試してみてください。 – fluffy

+0

エラー: 'エラー:(:1)引数1のタイプがgimp-image-widthに無効です' – Viktoria

関連する問題