glutanimate / image-occlusion-enhanced

Anki add-on that transforms images into cloze tests
https://ankiweb.net/shared/info/1374772155
Other
396 stars 41 forks source link

Auto-fit to canvas malfunctioning #92

Open sarahlippinc opened 5 years ago

sarahlippinc commented 5 years ago

What I expected to happen: I import a screengrab (from clipboard) and the zoom automatically fits to canvas What happens: I import a screengrab and the zoom is set to ~7%.

ghost commented 5 years ago

I also have this issue, I am running Anki 2.1 on Linux with the latest version of this add-on. The zoom varies between very low values like 30% and 7% but it would be ideal if it automatically started at 100%.

Here's a screenshot for reference: screenshot2019-02-22-095535

CPPbioNOR commented 5 years ago

I also have this exact issue with Anki 2.1.13 on windows10.

glutanimate commented 5 years ago

Thanks for the reports guys. I can confirm the issue here. It seems to be a problem with SVGEdit (the component used in the mask editor). I will see if I can address it somehow.

For the time being I would recommend clicking on the FIT button in the left toolbar whenever you load a new image into the editor.

dsc321123 commented 4 years ago

You can also just click control/command F and the image will resize to fit the current canvas.

jeremymoreau commented 3 years ago

I also have this issue on macOS 11.2.3 with Anki 2.1.35 and Image Occlusion Enhanced 1.3.0-alpha6. The image opens off-centre and too large, so I press cmd + F every time after opening the window.

Here's a very basic Alfred (https://www.alfredapp.com) workflow workaround I use in the meantime (mac only).

open image occlusion All this does is focus Anki, press cmd + shift + O, wait 2s, press cmd +F. Anki and the "Add" window must already be open. Default keyboard shortcut is alt + \

Open anki image occlusion.zip

MedBooster commented 2 years ago

Has anyone been able to make a script like this for Windows 10? I tried using Autohotkey, but it wouldn't work, possibly because it isn't enough to make the script activate the window it seems, you have to actually click inside the canvas, you can't click on the window tab for example.

MedBooster commented 2 years ago

To make the image you load from your clipboard in image occlusion you can make the image automatically fit to canvas (as long as you use a keyboard shortcut to open it, it is not enough to open the IO-window with your cursor. Based on pressing the keyboard shortcut a mouse click in the middle-ish of the screen is initiated (with a 1-2 sec delay, depending on how fast or slow your loading time is, as it is not enough that the window opens, the image in the canvas has to fully load before the "Mouse click in center → f" for centering the canvas works.

I have ~^+O:: set to ~^E:: because I changed the Ctrl+Shift+O image occlusion shortcut in the add-on to Ctrl+E https://www.autohotkey.com/ Of course it would be better if there were an option for the add-on to do this automatically itself, but until then, this is an OK temporary solution.

#ifwinactive ahk_exe Anki.exe
~^E::
;You can increase/decrease this based on how fast your image occlusion window loads
winwait, Add ahk_exe anki.exe,, 0.4
if errorlevel
{
msgbox, window took too long to open 
return
}
;You can increase/decrease this delay based on how fast the image in the canvas loads
sleep, 2500

; ↓ You can edit the X_Pos / Y_Pos values ↓
WindowTitle := "Image Occlusion Enhanced - Add Mode"
;The title of the image occlusion window
                ;note: you can get this title with the Window Spy script/app which should come installed with AHK. 

X_Pos := 800        ;The X position within the window you want to click
Y_Pos := 800        ;The Y position within the window you want to click

WinGet, WindowArray, List, %WindowTitle% 
;max 1 window with the given title
if !(WindowArray = 1)
{
    msgbox, % "More or less than one window found with the title: " WindowTitle "`Script will close now"
    exitapp
}
Window_UniqueID := WindowArray1
ControlClick, X%X_Pos% Y%Y_Pos%, ahk_id %Window_UniqueID%,,,, NA  

Text = f
Send %Text% 
return

Special thanks to ShambleS1980 on the AHK DIscord server. (and me, MedBooster :p)

glutanimate commented 2 years ago

Hey everyone, thanks for the reports! I thought this was fixed with v1.0.0, but it looks like it's still present in the latest version of the add-on (although perhaps happens less frequently than before). Added this to my TODO list.


Merging in some additional comments that might be helpful to debug this:

Extracted from @bwhurd's report in #179:

When the mask editor initially appears, the image should automatically fit to the bounds of mask editor. I press ^f every single time so I can see the entire image. I can't think of a reason why this wouldn't be the default behavior.

Debug info from /u/monamiici on Reddit:

Anki 2.1.54 (b6a7760c) Python 3.9.7 Qt 6.3.1 PyQt 6.3.1
Platform: Windows 10
Flags: frz=True ao=True sv=2
Add-ons, last update check: 2022-07-17 13:19:46

===Add-ons (active)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
Image Occlusion Enhanced for Anki 21 ['1374772155', 2022-04-09T02:15, 'None', '']
Improved Quizlet to Anki 21 Importer ['538351043', 2020-11-14T20:16, 'None', '']

===IDs of active AnkiWeb add-ons===
1374772155 538351043

===Add-ons (inactive)===
(add-on provided name [Add-on folder, installed at, version, is config changed])