Dudemanguy / mpv-manga-reader

Manga reading script for mpv
GNU General Public License v3.0
119 stars 4 forks source link

Adjust to width? #6

Closed ghost closed 3 years ago

ghost commented 3 years ago

Wondering if it's possible to adjust the images to the width of the screen when in single page mode (double page mode should work too I guess.) Is this possible to implement?

Dudemanguy commented 3 years ago

It shouldn't be impossible. There might be an mpv option that can already do this actually.

Dudemanguy commented 3 years ago

Oh duh. Just cycle the aspect ratio (shift+a). That should cover it I think.

ghost commented 3 years ago

This results in the images getting completely stretched...Scrolling/panning up and down would be the ideal scenario. Making the image zoom to screen width and then using the arrows. Just like in Yacreader or any other manga reader.

Dudemanguy commented 3 years ago

Sorry, I suppose I'm misunderstanding the request. Testing McComix, "fit to width" appears to zoom it at some arbitrary amount? I'm not really sure what exactly this parameter is supposed to be though.

Edit: Oh nevermind, I think I understand now.

Dudemanguy commented 3 years ago

Oh wait, doesn't the --autofit option cover this? You can set --autofit=100% for fitting to width and --autofit=0x100% for fitting to height. I think this is what you want.

ghost commented 3 years ago

Tried for an hour, doesn't seem to work. At least adding the command doesn't change anything.

Dudemanguy commented 3 years ago

autofit doesn't currently update on runtime so if you were adding a keybinding for it or setting it in the console it wouldn't appear to do anything. If you go forward and back a page it should trigger though.

Dudemanguy commented 3 years ago

Runtime geometry/autofit support was just added to mpv for x11 and wayland if you're on linux btw.

ghost commented 3 years ago

Yep! I'm on linux. Been trying to make it work these last few days but no luck...It just won't do a width fit. Stays the same no matter what I press. I tried doing the geometry commands for mpv but those don't work either. What do you suggest?

Dudemanguy commented 3 years ago

Well, mpv --autofit=100% /path/to/file/or/directory should launch a window that is resized to take 100% of your monitor's width. If that doesn't work, something is wrong here. If you want that for everything all the time, you could just set that in your mpv config or make a profile or something.

Now as for having a handy keybinding/toggle that enables that option on the fly it's not quite as easy. You can put something like KEY cycle-values autofit "100%" "" in your input.conf. This will correctly update the properties and you should see the values display in the OSC. However, the mpv window won't actually do anything because autofit (as well as geometry) doesn't update immediately on runtime. A workaround for this would be to change items in a playlist and then it should update.

However, the lack of runtime updates for the geometry/autofit options are fixed in mpv (for x11 and wayland at least) from the master branch. If you build mpv from git master, then the above mentioned input.conf keybinding will work on the fly and you can toggle the autofit option (fit to width in this case) on and off.

ghost commented 3 years ago

Awesome! Works now. Only thing that doesn't work is full screen. It works in windowed mode but as soon as you press F it resizes the image to height. Another issue is that the panning position doesn't reset to the top when changing pages.

Dudemanguy commented 3 years ago

Hmm yeah I don't know if getting that behavior in fullscreen is possible. mpv's fullscreen usage, of course, scales the entire image to fit on your screen. As a workaround you could perhaps use windowed mode but turn off the border and other stuff so it's a "pseudo-fullscreen".

Another issue is that the panning position doesn't reset to the top when changing pages.

Ah yeah, that would need a property observer. That's pretty simple to do. I'll try to think of a logical way to add it.

Dudemanguy commented 3 years ago

I know this is a super late response but --reset-on-next-file=video-pan-y will reset the y pan values everytime you change files. You can add video-pan-x to that as well if you are using that. As for the fullscreen request, it's orthogonal to the concept of fullscreen in mpv so I don't it's really possible. I'll close this one now.

NightMachinery commented 3 years ago

@Dudemanguy Any way to set the zoom level such that the current page fits to the width of the mpv? So that horizontal scrolling is never necessary?

Dudemanguy commented 3 years ago

autofit=100% should fit to width. Does it not?

NightMachinery commented 3 years ago

@Dudemanguy I tried it, but it was somewhat buggy and had different results as I restarted mpv. Anyhow, based on the man page, I think autofit fits mpv’s width to its content, while I want mpv to be full screen, and the zoom level of the content fit to mpv’s width.

Dudemanguy commented 3 years ago

I want mpv to be full screen, and the zoom level of the content fit to mpv’s width.

If you do the math, it would be possible to calculate the exact zoom level needed based on the size of the image.

Slider-Whistle commented 2 years ago

What a shame. Maybe I should bug the mpv developers about adding some more fullscreen settings for autofit. I haven't got vertical monitors, and reading comics feels wrong to me without being able to pan up and down, so this script can't really replace mcomix for me yet.

Slider-Whistle commented 2 years ago

@Dudemanguy Setting "panscan" to "1" in mpv config as long as "keepaspect" is also kept to "yes" appears to achieve the same results without the need to hardcode a solution designed for a single screen resolution, and as a bonus, automatically selects between preferring width or preferring height based on whichever is greater without any need for user intervention. I think this exactly replicates MComix's "Scale to width" and "Scale to height" functionality and then adds even more. Would you be able to make a note for visibility in the readme? I think it would please many comic readers to realise that mpv can already do this.

ghost commented 2 years ago

Very cool! It indeed seems to work with these two settings :D What still doesn't work is reset-on-next-file=video-pan-y When changing to the next page it starts in the middle, not at the top.

Dudemanguy commented 2 years ago

I totally forgot panscan was a thing.

What still doesn't work is reset-on-next-file=video-pan-y. When changing to the next page it starts in the middle, not at the top.

That's because the default value is zero. You would also need to set video-pan-y to be either 1 or -1 (I forgot which one is the top and which one is the bottom) in your config.

Slider-Whistle commented 2 years ago

@yaoberh "video-align-y=-1" in your mpv config profile, if you haven't tried it already.