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

Infinite loop in image editing (sometimes) #11

Open
darlopvil opened this issue Sep 19, 2022 · 6 comments
Open

Infinite loop in image editing (sometimes) #11

darlopvil opened this issue Sep 19, 2022 · 6 comments

Comments

@darlopvil
Copy link

darlopvil commented Sep 19, 2022

Hi,

After editing something in an external program/creating a new image, sometimes, it enters an infinite loop of [processing]. I use Paint.NET for that. After doing the edit issue, i press save and then the program closes, but Anki enters an infinite loop of "processing" the changes, i fear.

Also, the image ratio appears heavily altered, as you can see here:

imagen

Waited a few minutes, but it didn't do anything, so i just had to restart Anki. After that, the image editing changes appear without problem, so the edition process seems to work correctly.

Strangely, this doesn't happen every time while editing a pic. I've done some edition tests and there were all good (no infinite loop of waiting process), so i'm not sure when it may happen again.

@darlopvil darlopvil changed the title Infinite loop while saving changes (image edition) Infinite loop in image edition Sep 19, 2022
@ijgnd
Copy link
Owner

ijgnd commented Sep 19, 2022

thanks for posting this.

I've never run into this but this is the second report I got about this.

you can avoid this by changing the setting "image_edit_externally__block_Anki_during_edit" to false, but then you won't directly see the modified image in the editor because anki will still show you the cached version.

I'll have to think about this for a while:

  • Maybe I'll just add an option "Clear Cache" to the context menu that you need to run after editing the image.
  • Maybe I should show an askUser dialog ("external image edit finished?")?
  • When a user starts editing an image externally I could start watching the file for changes and if one is detected I could clear the anki cache. I should always stop this watching when (in the add window) this note is added, (in the browser) when a different note is loaded into the editor, (in the preview) when the window closes. But I wonder what happens if I clear the cache at a random time ...

@ijgnd ijgnd changed the title Infinite loop in image edition Infinite loop in image editing (sometimes) Sep 19, 2022
@ijgnd
Copy link
Owner

ijgnd commented Sep 19, 2022

I made a different issue for the image ratio problem.

@darlopvil
Copy link
Author

you can avoid this by changing the setting "image_edit_externally__block_Anki_during_edit" to false, but then you won't directly see the modified image in the editor because anki will still show you the cached version.

So when does Anki change the edited pic? After adding the card to the deck (in the Add Window) and after closing and choosing other card (in the explorer)?

I'll have to think about this for a while

Ok, it seems to be more difficult than the last issue #10 np man

@ijgnd
Copy link
Owner

ijgnd commented Sep 19, 2022

I'll upload a fixed version for 2.1.49 or lower and change the add-on description.

when does Anki change the edited pic

your notes are just html. when you press ctrl+shift+x on a field you'll see what anki actually stores. for images it's <img src="image_name"> and the file image_name is in the folder collection.media in your profile folder.

In the long run you'll always see the actual image from the image folder.

At the latest after restarting anki. But it should be enough to start a new editor instance, e.g. after adding a note and then viewing it in the browser or doing a review will reload the actual image from your media folder.

When images are reloaded from the media folder in the editor (in the same editor instance) seems to have changed in 2.1.50 so that it's no longer enough to just clear the cache. Whereas editor.web.page().profile().clearHttpCache() had an effect up to .49 it's no longer enough for 2.1.50+.

I'm still on .49 so I have not looked into this. I don't know if and when I'll have the time to look into this for 2.1.50. Certainly only after I have started using these modern versions.

Maybe there are other add-ons that work better like Image Editor.

@darlopvil
Copy link
Author

Hey man, no pressure. Don't get me wrong. I really love your add-on. If I have to wait for a new enhance-bugfix release, I'll do it without hesitation. Take your time to study the new code changes. Image editors aren't something that people normally would continuously be updating, there are a lot of dead/abandoned projects. So, as long as you don't forget about this one, i'll write issues if something is wrong, just that.

Programming often is unrewarded, although being very time-consuming. I appreciate your fast answers, but i'm not begging for an instant update. Again, take your time.

In the meantime, i'll follow your suggestions. And yeah, Image Editor is a cool add-on, but being so tied to a ready-made editor without many good features can be kind of annoying.

@jaredagordon
Copy link

jaredagordon commented Oct 7, 2023

_*** Maybe I'll just add an option "Clear Cache" to the context menu that you need to run after editing the image.

  • Maybe I should show an askUser dialog ("external image edit finished?")?
  • When a user starts editing an image externally I could start watching the file for changes and if one is detected I could clear the anki cache. I should always stop this watching when (in the add window) this note is added, (in the browser) when a different note is loaded into the editor, (in the preview) when the window closes. But I wonder what happens if I clear the cache at a random time ...**_

Hey @ijgnd, is there any way to add this line of reasoning for when the 'show image in finder' option is selected? On Anki 2.1.65qt5 MacOS.

I ask this because I use this option to edit the images since it allows me to take advantage of the Quick Look -> Markup feature (from Preview), which somehow bypasses the permission issues of editing the image via triggering the external editor. However, I still run into the same issue of the Anki browser not updating these changes.

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

3 participants