Before/After view

Hello, perhaps I’m doing something wrong, but when I use the following code:

(via a screenshot as I cannot paste code here without that being reformatted by the forum software)

… and I choose Forward horizontal in the G’MIC plugin for Gimp and say OK, then the following image is created:

Zooming in to the upper left corner shows the Before text:

All the preview options show the same effect (except Full of course). Anyone sees what I am doing wrong?

G’MIC plugin version 1.7.4pre#071216

I’m not surprised :slight_smile:
In line :

#@gimp ViaNewLayers : mylayers, mylayers(0)

you tell that the filter preview must be generated by the G’MIC command -mylayers. This command precisely generates an image intended to be an image preview (as it use command -gimp_split_preview). So when you apply the filter, you get this before/after separation.

What you need to do is actually create two commands :

  • One command that will be applied only when you apply the filter, probably command -mylayers:

    mylayers :
    -gimp_adjust_colors $1,$2,0,0,0,0
    -gimp_unsharp_octave $3,4,3,0,0,0,24,0

This command obviously has to ignore the last parameter of the filter (parameter Preview).

  • One different command mylayers_preview that will be applied only to compute the image preview (taking the Preview parameter of the filter into account.
mylayers_preview : 
  -gimp_split_preview "-mylayers $*",$-1

Note that only one -gimp_split_preview command is needed. Always.

The define your filter like this :

#@gmic ViaNewLayers : mylayers, mylayers_preview(0)

Salut David,

So I was feeding the before/after view to the filter, instead of the photo itself! Stupid me… :wink:

Okay, things are more clear now and the updated code works as expected, thanks for your help. I’ll update my articles about writing G’mic plugins for Gimp as well.

You can actually paste code inline using backticks: `like this` = like this

Or using “code fences” where you start and end a code block with triple backticks:

```
mylayers :
-gimp_adjust_colors $1,$2,0,0,0,0
-gimp_unsharp_octave $3,4,3,0,0,0,24,0
```

will yield:

mylayers : 
  -gimp_adjust_colors $1,$2,0,0,0,0
  -gimp_unsharp_octave $3,4,3,0,0,0,24,0

You can also indicate code by preceding all of the lines with 4 spaces:

mylayers : 
  -gimp_adjust_colors $1,$2,0,0,0,0
  -gimp_unsharp_octave $3,4,3,0,0,0,24,0

You can also set the language used by the code for syntax highlighting purposes if auto-detection fails when using a code fence, by appending the language keyword after the opening code fence:
```bash

Thanks Pat, I knew it was possible to paste plain code (as David did).
I’ll try
backticks for single lines of code
and
triple backticks for

my_bad_code : 
    -gimp_test1 $1,3
    -gimp_test2 $2,6

Ah, that seems to work!

The 4 spaces trick does this:

my_bad_code : 
-gimp_test1 $1,3
-gimp_test2 $2,6

So triple backticks for me!

triple backticks+bash gives:

my_bad_code : 
    -gimp_test1 $1,3
    -gimp_test2 $2,6

I’ll try that as well when other things fail, thanks.

1 Like