WIP: Unified Image VIewer for G'MIC

I know it is displayed on the selected image, but maybe having the image names (if named) always shown on (or under, or above) the thumbnails would be useful to quickly identify them from the list (even if truncated)?

I’m against this idea because sometimes my images are named as something else even if I did not apply name to them.

Very good!

1 Like

Progress report #2:

  • I’ve been finally able to implement the Image shift/zoom feature. For now, shift is done using the left muse button, and the zoom uses the mouse wheel. But this will probably change in the future. I find it quite intuitive, and it’s easy to control entirely with my touchpad.

  • I’ve also done quite a lot of code cleaning and simplification, even for the thumbnail browser.

  • Next step: add more elaborated cursor at the pixel level, and display information about selected pixels. After that, this should be really usable as a replacement for current display2d.

  • I need also to implement options to control how the value normalization is done, as well as how the aspect ratio can be controlled. For now, there is a strict respect of the aspect ratio, but for weird-sized images, it’s not that practical (e.g. image with size 10000x1).

Anyway, I think I’ve implemented the most difficult part for the 2D viewer!

Feel free to try and report weird behaviors if any :slight_smile:

1 Like

I like the (CTRL+) arrows shortcuts to switch images :slight_smile:

Will you put back the “selection zoom” (left click + drag) too?

Also, the TAB key show/hide the thumbnail navigation toolbar!

Yes, that’s planned. Image shift will be done with 3rd button in the future (but I haven’t one on my touchpad, so for testing purpose this was easier with the left mouse button).


There is a strong inconsistence of content and displayed coordinates:
gmic osteo .x2 log nd
Bildschirmfoto 2023-08-11 um 22.37.29

Point coordinate should be about 63,84. Happens only with more than one image. Additionally, coordinates in enlarged subwindows are not correct. Seemingly only y coordinate is affected.

1 Like

Indeed, I’ve found that just before going to sleep.
Fixed with:

I’ve just started the work on info display, so it’s definitely not done :slight_smile:

Very good!
Besides that, I am a bit confused by Left and Right with cursor inside the canvas, a certain padding?
Maybe a list of key functions with modifiers would be helpful, for testing too!
There is a special (long) delay of termination after using ndispay a bit. Possibly some memory is running full?

By the way, I am using the Mac mouse on my laptop with Fn, Shift, Ctr and Alt modifier, touchpad and tablet trial will come later!

Could you be more precise ? What is confusing?

Does this happen when you have a lot of images ? Or just a single image ?
Optimization is something I need to do also, but once everything is in place.

padding: Left/Right/Up/Down moves the displayed image certain (arbitrary?) amounts of space, jumping. I would expect one pixel shifts similar to one thumbnail in the scrollbar

delay: Only with a lot of images, say 125 or so, but does not happen always. Looks a bit like heavy cleaning!

Progress report #3:

  • After two more days of work, I think ndisplay (temporary name) is now a valid replacement to the existing 2D image viewer in G’MIC display2d.
  • Everything I had in mind is implemented : image selection, pan/zoom/crop + various options to choose normalization mode (CTRL+N), toggle pixel grid (CTRL+G, when zoomed in), snapshot (CTRL+S), instance dump as .gmz file (CTRL+O), fullscreen mode (CTRL+F), and to easily navigate inside the image : (CTRL+left button or middle button to pan), mouse wheel or right mouse button to zoom in/out.
  • Aspect ratio of images is always preserved. Not sure if this is good or not, I may add an option to control this in the future (CTRL+R probably).
  • I’ve also found a quite nice optimization trick to render the canvas view, so the viewer should be definitely faster now (I can’t hear my CPU fans swirling anymore).
  • I’ve also fixed a memory leak (images were created and never removed in the image list), so it may also fix the issue @KaRo had. Let me know!

I’ve just pushed an update, so feel free to test and tell me what you think about it.

I’d really want ndisplay to become my ultimate image viewer in the future :slight_smile: At least, it will probably become the default image viewer in next G’MIC version (3.2.7).


In deed, nice work!
The termination delay did not appear anymore. An hour ago I had some minor problems with the panning limits, with/without zoom and with/without subwindows, has seemingly gone. The repeated normalization during zoom and panned subwindows needs some habituation or usage of CTRL N.

Perhaps some negative zoom via mouse wheel could have been added.

Perhaps also HOME and END should only affect left and right center and PAGEUP and PAGEDOWN only upper and lower center. On my keyboard that is all FN ARROWLEFT/RIGHT/UP/DOWN, comparingly simple, however a bit difficult with a tablet or touchpad only!

In my experience, I think it’s a good idea because there are cases where you really need to check the values. Case in point, development of combinatorics tool I made. I was comparing the output with Python itertools, and it wouldn’t be easy if it didn’t refit.

I found a bug. ndisplay doesn’t have alpha support. Also, in case of 4 channels, one could shift to cmyk mode, but that’s probably not needed. 5 channels is assumed to be cmyka mode. And 6 channels or more could have selected channels viewing. That way one can see through other channels. Maybe even display more numbers.

It’s not a bug, but a planned feature.
CTRL+A will toggle alpha-channel mode.

Note that there are plenty of cases where 4-channels image does not mean “image with alpha”, so alpha display won’t be enabled by default.

Very good, David.
The negative zoom is good for quick looking (for me). PAGEUP/DOWN seems to move a certain piece in y, in contrast to HOME and END, still in x and y centering.

After zooming around the pan range is a bit IMHO arbitrary, at least with neg. zoom!
By the way now (on my macbook)
CTRL left mouse or CTRL one finger press touchpad defines a subwindow
left mouse or one finger touchpad pans
wheel, right mouse or two finger touchpad zooms (have no middle button)
wheel quick move
Thats not bad!

HOME and END respectively go to the upper-left and lower-right corners of the image. This is intended. This is particularly useful when you deal with large Mx1 or 1xN images. The same keys allow to go at the start or the end of the image data.
For regular 2D images, this has few interest to use them I think.

Progress report #4:

  • Small improvements done here and there. I’ve decided that keeping the aspect ratio is a good idea finally, so I won’t implement something specific to display images without preserving the aspect ratio. The ways we can navigate in the images are enough to be able to get the relevant image information without needs to “distort” the image.

  • I’ve implemented an “alpha-channel” view mode, that is available with CTRL+A. Works only for images with 2 or 4 channels obviously.

  • As the viewer is now better than what we had before (with command d2d), I’ve made it the default viewer run by G’MIC. This obviously required changes in the C++ code of gmic.cpp, so a new build of the gmic binary is necessary to get this feature. I’ll try to provide builds for Windows this afternoon.

  • Now, I have to propose more viewer features for 3D volumetric images, as well as 3D meshes. The idea is to have all these integrated into the same viewer.

I did use them for regular images in zoom mode!