I like the idea of having similar names for both commands, as both commands clearly work together. As a non-english speaker, I think it really helps remembering their names.
As a native spanish speaker, I have to say that I prefer reserve - recover.
Reserva = Reserve
Recuperar = Recover
But, store and restore is easier to remember as all you need to remember is store, and only add re to do something else.
Well, what I see from the Merriam-Webster dictionnary is :
-
Store : to place or leave in a location (such as a warehouse, library, or computer memory) for preservation or later use or disposal
-
Restore: to bring back to or put back into a former or original state
My understanding of that is we cannot be more close to what these commands does in G’MIC
store
has indeed the meaning of moving something in another place (so here, an image, from the image list to a variable), and restore
brings the image back.
No problem. Just adding to the discussion.
Just for info : Today, I’ve implemented the store
and restore
commands, as custom commands in the stdlib
.
As a result, scripts using these commands (introduced natively in 2.7.2) should work also with previous versions 2.7.0 and 2.7.1 of G’MIC (they will just be a little slower though).
So, do not hesitate to use store
and restore
commands in your scripts already !
-
Commands
img2var
andvar2img
have been moved to my personal update filedavid_tschumperle.gmic
, to ensure the recent scripts from @Reptorian continue to work (but if you can replace their use withstore
andrestore
, it would be better). Not sure how long they will stay there. -
There are anyway small differences between the native and custom versions of
store
andrestore
. I don’t think that’s going to be a problem, though.
Have I hit a limit? This works
gmic sp tiger +store input fftpolar +.. 1 log.. store mag,phase restore input,mag,phase
but when I input a larger image such as heal_mushrooms.jpg, I hit a wall
[gmic] *** Error in ./store/*if/*substitute/uchar2base64/ *** Command 'eval': gmic<float>: Function 'copy()': Out-of-bounds image pointer (length: 2, increment: 1, offset start: 92434578, offset end: 92434579, offset max: 92434575).
Yes, that’s one difference with the ‘native’ versions of the commands.
Your example works with 2.7.2_pre currently.
You mean the native versions can handle this? I am confused which ones are native and which ones aren’t…
@David_Tschumperle I figured it out, and changes work on my tiled form filter. If you’d like, you can remove the arg2var and var2img.
Yes, that’s it.
Native versions of store
and restore
are basically there is you are using G’MIC 2.7.2.
Before that version, the limited custom versions of these commands applies.
Oh, I think I know what you are saying: native overrides stdlib
. Since I haven’t updated core yet, I am using stdlib
's.
You could check https://gmic.eu/files/prerelease/, where a Windows build of G’MIC 2.7.2 is available for testing.
After thinking about it, it would be interesting to use store and restore command to replicate this -
Is it feasible? Right now, all I can think of is a gui filter that uses text input. Rather tiring to do it manually.
I just have one issue with store and restore. I really don’t want to see this in preview when using code[local]. The command is basically for reverse engineering gradient map.
Same thing with apply_tiles.
Oh no. I do think this has to do with store.
All I did was apply rep_form_pixel to 4096 (Squared) Nebulous Image.
Worked a second time, I don’t know what happened.
Looks like he has found the same limitation as you did with the custom versions of store
and restore
.
@Reptorian, are you running latest version 2.7.2 of the plug-in ?
2.7.2_pre#190912 via Krita 4.3 pre-alpha
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 writingsample lena store lena $lena
is enough (asinput
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).
restore
was an odd command to me. This makes more sense.