Additional commands following LUT application

I am trying to apply a vignette filter after applying a LUT and I ended up with gmic image.jpg ‘Agfa.png’ ‘map_clut[0]’ ‘[1]’ ‘o[0]’ -.png | gmic -.png vignette , o test.png

Where do I find more information on how to send the output of the map_clut directly to the vignette function without going through a pipe? I ended up with this as map_clut seems to ask for an output file name…

Thanks a lot. I wonder why I took me so long to discover gmic

Hi,

You can chain gmic commands on the same line, no need to pipe gmic to another instance of gmic.

gmic run ' image.jpg Agfa.png map_clut[0] [1] vignette[0] , -o[0] test.png'

Also, you don’t have to save the file after every command, except if you want to save the result at that point in your pipeline. You can also use the d command (display)
Let me quote @grosgood about it:

Use the G’MIC display as a script breakpoint . The display command stops your script, dumps the image list to the shell and visualizes it. Now, New and Improved! You can observe the state of your script at the point of display. Drop as many as you want. Drop one after every executable line to emulate single-stepping.

1 Like

That’s because we try to keep it a secret (Who gave Helmut the tip-off??!??).
Ah me. Now that you have tumbled onto the game, here’s (I hope) A gentle introduction to it.

1 Like

Thank you - now it is obvious to me. Is there, by the way also a way of referencing the original inout file? I would like to resize with a height of 200, 1220, 1600 and 2000 pixels and it would be great if I would not have to re-load the original images 4 times.

Yes, there seem to be traitors everywhere there days…

$ gmic image.png clut.png map_clut[0] [1] remove[1] vignette , sizes=200,1200,1600,2000 repeat 'narg($sizes)' { 'size:={[$sizes][$>]}' +resize2dy[0] '$size' output[-1] 'thumb_$size.jpg,75' remove[-1] } remove

gives:

[gmic]-0./ Start G'MIC interpreter (v.3.2.7).
[gmic]-0./ Input file 'image.png' at position 0 (1 image 512x512x1x3).
[gmic]-1./ Input file 'clut.png' at position 1 (1 image 512x512x1x3).
[gmic]-1./ Map color LUT [1] on image [0].
[gmic]-2./ Remove image [1] (1 image left).
[gmic]-1./ Add vignette effect to image [0], with strength 100 and size 70.
[gmic]-1./ Set local variable 'sizes=200,1200,1600,2000'.
[gmic]-1./*repeat/ Set local variable 'size:=200'->'200'.
[gmic]-1./*repeat/ Resize 2D image [0] to 200 pixels along the y-axis, while preserving 2D ratio.
[gmic]-2./*repeat/ Output image [1] as jpg file 'thumb_200.jpg', with quality 75% (1 image 200x200x1x3).
[gmic]-2./*repeat/ Remove image [1] (1 image left).
[gmic]-1./*repeat/ Set local variable 'size:=1200'->'1200'.
[gmic]-1./*repeat/ Resize 2D image [0] to 1200 pixels along the y-axis, while preserving 2D ratio.
[gmic]-2./*repeat/ Output image [1] as jpg file 'thumb_1200.jpg', with quality 75% (1 image 1200x1200x1x3).
[gmic]-2./*repeat/ Remove image [1] (1 image left).
[gmic]-1./*repeat/ Set local variable 'size:=1600'->'1600'.
[gmic]-1./*repeat/ Resize 2D image [0] to 1600 pixels along the y-axis, while preserving 2D ratio.
[gmic]-2./*repeat/ Output image [1] as jpg file 'thumb_1600.jpg', with quality 75% (1 image 1600x1600x1x3).
[gmic]-2./*repeat/ Remove image [1] (1 image left).
[gmic]-1./*repeat/ Set local variable 'size:=2000'->'2000'.
[gmic]-1./*repeat/ Resize 2D image [0] to 2000 pixels along the y-axis, while preserving 2D ratio.
[gmic]-2./*repeat/ Output image [1] as jpg file 'thumb_2000.jpg', with quality 75% (1 image 2000x2000x1x3).
[gmic]-2./*repeat/ Remove image [1] (1 image left).
[gmic]-1./ Remove image [0] (0 images left).
[gmic]-0./ End G'MIC interpreter.
2 Likes

Thanks, David, this is the best support I have ever experienced in the open source space. So, thank you so much!

2 Likes

+<some command> has duplication semantics. Also, citing an isolated selection decorator in a pipeline duplicates the cited image. There is also a multiplier notation: [0]x4 makes four copies of the first image on the list. The command r2dy seems to fit your ticket. +r2dy[0] 200 duplicates the first image on the list and resizes, preserving aspect ratios, to a height of 200 pixels.

1 Like

Hi,

found out about this recently too. I have a little question about it : when/where can the multiplier be used? Only with input (or nothing)?

Yes, it’s only for “Special Input Strings”, as described in G'MIC - GREYC's Magic for Image Computing: A Full-Featured Open-Source Framework for Image Processing - Input Data Items

1 Like

Thanks, I think I should read (and re-read) these pages every day !

n[quote=“prawnsushi, post:10, topic:39015”]
when/where can the multiplier be used?
[/quote]

No joy:

$ gmic 128,128,1,1,'u(255)' r2dx[0]x4 200%
[gmic]-0./ Start G'MIC interpreter.
[gmic]-0./ Input image at position 0, with values 'u(255)' (1 image 128x128x1x1).
[gmic]-1./ Input file 'r2dx[0]x4' at position 1
[gmic]-1./ *** Error *** Unknown command or filename 'r2dx[0]x4'; did you mean 'r2dx'?

won’t work if the selection decorator is attached to a command, but:

gmic 128,128,1,1,'u(255)' +r2dx. 200% [0,1]x4

produces five pairs of small and large noisy images. Any valid image selection works, so

… [^0--1:2]x2 …

duplicates every odd-numbered item on the list. and

$ gmic '(255,255,255^255,127,63^0,20,40)x3'

gives three sets of orange pixels.


3 Likes

This :

Awesome. More ways to eat RAM! Thanks!