Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Open File dialog crashes nip2 when you paste a path "Recent" is selected #113

Open
Ark-kun opened this issue Feb 11, 2024 · 6 comments

Comments

@Ark-kun
Copy link

Ark-kun commented Feb 11, 2024

It's my first time using nip2 and I'm very excited.

After an hour of searching around I found documentation and it told me that images need to be imported via "File/Open" menu.

The dialog I saw was ...intresting... . It made me nostalgic, remembering the 80s and 90s. So many diverse and colorful file dialog designs.

Anyways, I did not really want to traverse the whole directory hierarchy with my mouse. I had a directory path in clipboard, but I saw no field to paste it. So I just pressed Ctrl+V to paste it ...somewhere... . And the whole nip2 program just crashed. I've tried again and it seems reproducible.

I wonder whether using system-native dialogs would have prevented this issue.

image

@jcupitt
Copy link
Member

jcupitt commented Feb 11, 2024

Hello @Ark-kun,

Yes, it's a blast from the past isn't it. nip2 was my weekends project for most of the late 90s and the world has moved on.

It has recently become hard to support since most of the GUI dependencies (especially goffice) have dropped out of the major repositories. I've begun a project to rewrite it for gtk4:

https://github.com/jcupitt/nip4

I've done the image viewer already:

https://github.com/jcupitt/vipsdisp

I'm hoping to have it mostly done by the summer. The idea is to just rewrite the GUI layer for gtk4 and leave everything else intact. It ought to be backwards compatible, though with a modern look and some useful improvements.

To answer your question -- yes, nip4 uses the system file dialog. gtk2 (which nip2 is based on) did not support this, unfortunately.

There are a few workarounds which might help:

  1. You can drag-drop files from the system file manager onto the nip2 main window -- you'll get a new cell at the bottom of the current column.
  2. You can also drop onto a cell and it'll replace it.
  3. The nip2 file dialog is not modal and has a "pin me up" option to stop it popping down on "OK". This is very handy combined with "replace from file" --- you can put the file dialog on the left of the screen, have some processing in the middle, and have an output window on the right. You can press "enter" and cursor down in the file dialog and quickly try a workspace on a whole directory of images.
  4. You can also load groups of files. Click on the first one, shift-click on the last, press "Load" and you'll get a group of images. Groups are a way to do batch processing -- most menu operations on a group will give a new group with the operation applied to every member.

@jcupitt
Copy link
Member

jcupitt commented Feb 11, 2024

nip4 should have a much better windows build too. There's a test build of vipsdisp (what will become the nip4 image window) for windows here:

https://github.com/jcupitt/vipsdisp/releases/tag/v2.6.3

Any feedback / testing would be very welcome.

@Ark-kun
Copy link
Author

Ark-kun commented Feb 16, 2024

Thank you for your patience and sorry for suddenly dumping a bunch of issues in the repo. I did not realize that this project was so old (the latest releases were pretty recent (although the Windows release is slightly older)).

The day I discovered nip2 I was going on a day-long wild chase of image processing software for programmers to do a pretty simple compositing. ImageMagick -> GraphicsMagic -> ImageMagick -> libvips.
I considered this project to be the latest experimental bleeding edge since I during my fast jumping around different projects I got impression that the libvips is the "latest and greatest/fastest" (but maybe not the easiest) way to manipulate the images programmatically. And I though that naturally a GUI for such project is even more bleeding edge and experimental. I somehow missed the long history of the project that goes way back. This explains some of the design choices and also makes the project even more impressive.

It's interesting to see that the nip4 has just started.

@Ark-kun
Copy link
Author

Ark-kun commented Feb 16, 2024

BTW, if you're interested, I can share my use case scenario. Just a usage data point.
My scenario is pretty trivial. I needed an operation that is opposite of "normal" composing of two images with alpha blending.

The formula for "normal" alpha blending is.

combination.color = back.color * (1 - front.alpha) + front.color * front.alpha

And I needed to perform the opposite operation to recover the original background:

back.color = (combination.color - front.color * front.alpha)/(1 - front.alpha)

With the caveat that the front and back image sizes are different, so they need to be properly centered.

The idea of "spreadsheet for image manipulation" seemed to fit perfectly for what I needed to do. My idea was to use nip2 to experiment with compositing, tweak the workflow until the results look good and then use the command line.

@jcupitt
Copy link
Member

jcupitt commented Feb 16, 2024

Hmm, kinda works:

image

Here's that workspace:

unblend.zip

Load it into nip2, then drop your test images into cells A1 and A3.

You can use nip2 from the CLI, it has a no-GUI batch mode. You can run something like:

$ nip2 -b unblend.ws \
    --set 'Workspaces.tab2.A1=Image_file "x.png"' \
    --set 'main=Workspaces.tab2.B14.value' \
    -o zz.png

Will run the workspace in batch mode, set A1 to the file x.png, set main (the value that will be computed) to the value of the final cell, and than save that value to zz.png. You can use your shell to loop over a directory of files.

Section 4.5 in the manual has the details.

@jcupitt
Copy link
Member

jcupitt commented Feb 16, 2024

Batch mode is a bit harder on windows since they (strangely!) have different binaries for GUI and non-GUI programs. You need to use the CLI wrapper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants