Store and Restore

So that’s probably one pre-release that didn’t contain the native versions of the store and restore commands. Try updating to latest stable version instead, it should work better.

I tested it, I get the variable store/restore not assigned. By Layer option for GUI Tiled Form worked before. Now it doesn’t.

gmic sp lena sp tiger rep_form_pixel -1,5,5,100
[gmic]-0./ Start G'MIC interpreter.
[gmic]-1./ Input sample image 'lena' (1 image 512x512x1x3).
[gmic]-1./ Input sample image 'tiger' (1 image 750x500x1x3).
[gmic]-2./rep_form_pixel/ Set local variable 'sid=-1'.
[gmic]-2./rep_form_pixel/ Set local variable 'isnum_sid=1'.
[gmic]-2./rep_form_pixel/ Set local variable 'isint_sid=1'.
[gmic]-2./rep_form_pixel/ Set local variable 'isnis=1'.
[gmic]-2./rep_form_pixel/ Set local variable 'isnum_sid=1'.
[gmic]-2./rep_form_pixel/ Set local variable 'isint_sid=1'.
[gmic]-2./rep_form_pixel/ Set local variable 'isnis=1'.
[gmic]-2./rep_form_pixel/ Store image [0] as variable 'shape_reference'
[gmic]-2./rep_form_pixel/*if/ Resize image [0] to 750x500x100%x100% , with no interpolation, dirichlet boundary conditions and alignment (0.5,0.5,0,0).
[gmic]-2./rep_form_pixel/*if/ Resize image [1] to 750x500x100%x100% , with no interpolation, neumann boundary conditions and alignment (0.5,0.5,0,0).
[gmic]-1./rep_form_pixel/*if/*if/ Apply command 'restore shape_reference rv _rep_form_pixel -1,5,5,100' on all image [1] in parallel, using 12 threads.
[gmic] *** Error in ./rep_form_pixel/*if/*if/apply_parallel/_apply_parallel/*if/ *** *** Error in ./rep_form_pixel/*if/*if/(...)/*thread0/_ap/*repeat/*local/ *** Command 'restore': Variable 'shape_reference' has not been assigned.

While trying to guess what happens with the restore command (see this thread), I realized that a better approach for ‘restoring’ an image could be simply to use the input command with the variable name as an argument.
So, that’s what I’ve implemented tonight, and you can now do this:

foo : 
   sample lena
   store. lena
   input $lena

This seems very logical, as the store command actually assign a variable with the binary content of an image. The good thing with associating the restore behavior with the input command is:

  • You don’t even need to specify input, so writing sample lena store lena $lena is enough (as input is the only command that can be replaced by nothing).
  • You have the possibility to insert multiple instance of the stored image at different locations of the image list, such as sample lena,bottles,eagle store[0] lena i[0,1] $lena.

I really find this syntax to be logical, so I’ll remove the native version of the restore command in the next stable release (but it will still be usable, as a custom command).

:clap: restore was an odd command to me. This makes more sense.

1 Like