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

Advanced Paste: Image To Text doesn't work with English (Canada) #37405

Open
t-makaro opened this issue Feb 12, 2025 · 3 comments
Open

Advanced Paste: Image To Text doesn't work with English (Canada) #37405

t-makaro opened this issue Feb 12, 2025 · 3 comments
Assignees
Labels
Cost-Small Small work item - 0-8 hours of work Issue-Bug Something isn't working Product-Advanced Paste Refers to the Advanced Paste module Status-In progress This issue or work-item is under development

Comments

@t-makaro
Copy link

Microsoft PowerToys version

0.88.0

Installation method

PowerToys auto-update

Running as admin

Yes

Area(s) with issue?

Advanced Paste

Steps to reproduce

Image

When English (Canada) is the only language pack installed, I use Win+Shift+S to screenshot a part of the screen, and then I go to advanced paste and use "image to text".

✔️ Expected Behavior

Image to text should work without needing an additional language pack.

❌ Actual Behavior

When I use image to text I get this:
Image

Looking at the logs I can see a line that says System.InvalidOperationException: Unable to determine OCR language.

Upon installing English (United Kingdom), the above image to text works just fine. Text extractor and the snipping tool's text extract both work fine without the additional language pack.

Other Software

No response

@t-makaro t-makaro added Issue-Bug Something isn't working Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams labels Feb 12, 2025
@cryolithic
Copy link

cryolithic commented Mar 5, 2025

Running into the same issue.

Logs show:

[14:30:02.4834908] [Trace] TransformHelpers.cs::ImageToTextAsync::60
[14:30:02.5192052] [Error] OptionsViewModel.cs::ExecutePasteFormatAsync::444
    Error executing paste format
System.InvalidOperationException: Unable to determine OCR language
Stack trace: 
   at AdvancedPaste.Helpers.OcrHelpers.ExtractTextAsync(SoftwareBitmap bitmap, CancellationToken cancellationToken)
   at AdvancedPaste.Helpers.TransformHelpers.ImageToTextAsync(DataPackageView clipboardData, CancellationToken cancellationToken)
   at AdvancedPaste.Helpers.TransformHelpers.TransformAsync(PasteFormats format, DataPackageView clipboardData, CancellationToken cancellationToken, IProgress`1 progress)
   at AdvancedPaste.Services.PasteFormatExecutor.<>c__DisplayClass3_0.<<ExecutePasteFormatAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at AdvancedPaste.Services.PasteFormatExecutor.ExecutePasteFormatAsync(PasteFormat pasteFormat, PasteActionSource source, CancellationToken cancellationToken, IProgress`1 progress)
   at AdvancedPaste.ViewModels.OptionsViewModel.ExecutePasteFormatAsync(PasteFormat pasteFormat, PasteActionSource source)
[14:30:02.5201693] [Debug] OptionsViewModel.cs::ExecutePasteFormatAsync::452
    Finished executing ImageToText from source ContextMenu; timeTakenMs=43
[14:34:54.5124906] [Trace] MainPage.xaml.cs::LoadClipboardHistoryAsync::57

@cryolithic
Copy link

Issue appears to be due to the LanguageTag excluding valid options. I don't know what repercussions removing the tag from the selection would have on other languages.
In my test, for en-CA, rather than using TryCreateFromLanguage, TryCreateFromUserProfileLanguages created a valid ocrEngine.

@htcfreek
Copy link
Collaborator

htcfreek commented Mar 6, 2025

@cryolithic
Your contribution is welcome and thank you for your work on this. Feel free to open a PR. If you have any further questions don't worry to ask them.

@htcfreek htcfreek added Status-In progress This issue or work-item is under development Cost-Small Small work item - 0-8 hours of work Product-Advanced Paste Refers to the Advanced Paste module and removed Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams labels Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Cost-Small Small work item - 0-8 hours of work Issue-Bug Something isn't working Product-Advanced Paste Refers to the Advanced Paste module Status-In progress This issue or work-item is under development
Projects
None yet
Development

No branches or pull requests

3 participants