thomasasfk / sd-webui-aspect-ratio-helper

Simple extension to easily maintain aspect ratio while changing dimensions. Install via the extensions tab on the AUTOMATIC1111 webui.
https://github.com/thomasasfk/sd-webui-aspect-ratio-helper.git
406 stars 66 forks source link

Automatic image size according to input image ratio does not work #46

Closed psykokwak-com closed 1 year ago

psykokwak-com commented 1 year ago

Hello, Since last few update, the automatic image size based on the input image ratio does not work. See below :

gif

And here the javascript error I got :

aspectRatioController.js?1681108525.8360796:430 Uncaught TypeError: Cannot read properties of null (reading 'querySelector')
    at aspectRatioController.js?1681108525.8360796:430:45
    at Array.forEach (<anonymous>)
    at postImageControllerSetupFunction (aspectRatioController.js?1681108525.8360796:428:32)
    at MutationObserver.<anonymous> (aspectRatioController.js?1681108525.8360796:390:17)

aspectRatioController.js?1681108525.8360796:20 Uncaught TypeError: Cannot read properties of null (reading 'textContent')
    at getSelectedImage2ImageTab (aspectRatioController.js?1681108525.8360796:20:85)
    at getCurrentImage (aspectRatioController.js?1681108525.8360796:24:24)
    at AspectRatioController.setAspectRatio (aspectRatioController.js?1681108525.8360796:321:25)
    at HTMLSelectElement.<anonymous> (aspectRatioController.js?1681108525.8360796:118:24)
thomasasfk commented 1 year ago

Huh, thanks for reporting. Seems this line is throwing the error:

https://github.com/thomasasfk/sd-webui-aspect-ratio-helper/blob/ab303d6e979e9d916850ea609b621345a9cb27b8/javascript/aspectRatioController.js#L20

Wonder if the selector is brittle and something on the webui has changed... I'll give it a look.

thomasasfk commented 1 year ago

I can't seem to reproduce this, does this happen consistently for you? Wondering if the way the current tab is being grabbed is too brittle for different styles and themes...

psykokwak-com commented 1 year ago

Here my conf :

venv "C:\Users\Jyce\Desktop\stable-diffusion-webui\venv\Scripts\Python.exe"
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Commit hash: a9fed7c364061ae6efb37f797b6b522cb3cf7aa2

(Not the latest automatic1111 version)

conf

thomasasfk commented 1 year ago

The way I've done the tab detection is bad anyways, just realised coupling it to English is probably bad for localisations too! I'll look at alternative options.

thomasasfk commented 1 year ago

Also noticing that the styling doesn't work for your light them either. I'll take a look at that as well.

thomasasfk commented 1 year ago

@psykokwak-com thanks again for raising this, I've changed some things in https://github.com/thomasasfk/sd-webui-aspect-ratio-helper/pull/47 and merged to main.

Can you try updating your extension and seeing if your errors are gone? I'm still not sure the root cause of your issue, my guess was that it was a different hierarchy of elements which wasn't being picked up by the following: https://github.com/thomasasfk/sd-webui-aspect-ratio-helper/blob/ab303d6e979e9d916850ea609b621345a9cb27b8/javascript/aspectRatioController.js#L20

I've since changed it to use the following: https://github.com/thomasasfk/sd-webui-aspect-ratio-helper/blob/905a8a0ac6ef26eae1ac0e56999bc4507859d84b/javascript/aspectRatioController.js#L18-L21

Which should hopefully resolve your issue.

The styling should also match your light theme now hopefully!

psykokwak-com commented 1 year ago

Hello @thomasasfk , thanks for your help. Unfortunately it still not work. The issue remains.

aspectRatioController.js?1681195824.9943304:27 Uncaught TypeError: Cannot read properties of null (reading 'querySelector')
    at getCurrentImage (aspectRatioController.js?1681195824.9943304:27:54)
    at AspectRatioController.setAspectRatio (aspectRatioController.js?1681195824.9943304:319:25)
    at HTMLSelectElement.<anonymous> (aspectRatioController.js?1681195824.9943304:116:24)

What can I do to help you ?

thomasasfk commented 1 year ago

Hello @thomasasfk , thanks for your help. Unfortunately it still not work. The issue remains.

aspectRatioController.js?1681195824.9943304:27 Uncaught TypeError: Cannot read properties of null (reading 'querySelector')
    at getCurrentImage (aspectRatioController.js?1681195824.9943304:27:54)
    at AspectRatioController.setAspectRatio (aspectRatioController.js?1681195824.9943304:319:25)
    at HTMLSelectElement.<anonymous> (aspectRatioController.js?1681195824.9943304:116:24)

What can I do to help you ?

Out of curiosity - is there any reason you aren't on the latest version of the A1111 webui? Is it because it may break your current workflow due to incompatible changes?

I've checked out the version with the old commit, and the styling on the page is different, so I'll need to make a decision on either handling backwards compatibility, only handling latest version, or implementing some version tagging system. I'll give it a think and see when I can have time to do it!

I probably should've thought about this sooner - but thanks for raising, sorry for the delay, if you use the latest A1111 webui it should work, otherwise will need to wait until I find time to implement some backwards compatibility and some productive way of testing it.

psykokwak-com commented 1 year ago

Thanks for your message. The latest A1111 version has lot of bugs. I have the impression that the project is being abandoned. The maintainer validates the PRs without really taking the time to test them. So with each new version, there are more bugs than in the old one.

thomasasfk commented 1 year ago

Going to close this issue for now, I'd prefer to fix forward and work on newer versions.

Not sure if I'll go back and retroactively implement the features for old versions, unless we have some statistics of old versions being incredibly popular.