Using variables - crop at width-30

Hi,

I want to crop scrollbar from browser screenshot and I don’t know the width of the image beforehand. I tried to find an answer, but I am running out of time without result. This is what I have now:

gmic.exe cost01.png -crop 100,70,${w}-30,770 -display

But it produces wrong result…

[gmic]-0./ Start G'MIC interpreter.
[gmic]-0./ Input file 'cost01.png' at position 0 (1 image 1280x800x1x3).
[gmic]-1./ Crop image [0] with selection (100,70) x (-30,770) and dirichlet boundary conditions.
[gmic]-1./ Display image [0] = 'cost01.png'.
[0] = 'cost01.png':
  size = (131,701,1,3) [1076 Kio of floats].
  data = (0,0,0,0,0,0,0,0,0,0,0,0,(...),84,84,84,84,84,84,84,84,84,84,84,84).
  min = 0, max = 255, mean = 195.425, std = 106.826, coords_min = (0,0,0,0), coords_max = (30,1,0,0).
[gmic]-1./ End G'MIC interpreter.

Maybe this :

gmic.exe cost01.png -crop 100,70,{w-30},770 -display

?

1 Like

Oh yea, that {w-30} works fine. I wish reference contained this example with a link to doc how to use variables, expressions and a list of that variables.

An expression inside braces is often evaluated as a math formula, and the reference has an entire section on it : http://gmic.eu/reference.shtml#section9
I know also that @grosgood have started to write a very nice tutorial about the use of the math expressions in G’MIC. I haven’t got news from him since a long time, I hope he is doing well.

1 Like