Stellarium / stellarium

Stellarium is a free GPL software which renders realistic skies in real time with OpenGL. It is available for Linux/Unix, Windows and macOS. With Stellarium, you really see what you can see with your eyes, binoculars or a small telescope.
https://stellarium.org
GNU General Public License v2.0
7.55k stars 813 forks source link

Let the screenshots have other format than PNG #623

Closed 10110111 closed 5 years ago

10110111 commented 5 years ago

As I can currently see in the code, the screenshot format is hard-coded to PNG. This makes saving screenshots in a loop (e.g. for a timelapse) very slow: each screenshot takes a lot of time to be encoded. Even worse, if one needs to further process them — e.g. do some stitching, combine into an animation, each of the screenshots in the sequence will again need to be decoded before processing, which takes about the same time.

So, it'd be great if I could e.g. choose BMP. QImage does support it, I just checked it by re-hard-coding the suffix in both places to .bmp, so this request is to provide a scripting (and GUI? not sure if we can make screenshots from the GUI) interface for choosing the format.

gzotti commented 5 years ago

Should not be difficult I hope. I just think PNG is the much better format. BMP is such a waste of space! If we do it, JPG would be an obvious third format, or even TIF with lossless LZW compression.

BTW, for animations, it is much easier to just capture and record the screen. Use Windows 10's Win-G key combination to open the Game menu and record into MP4 (beware, it also records the mouse cursor...). For other systems, there are 3rd-party screen recorders.

alex-w commented 5 years ago

I think the movie recorder may be ported from Celestia :)

10110111 commented 5 years ago

I just think PNG is the much better format. BMP is such a waste of space! If we do it, JPG would be an obvious third format, or even TIF with lossless LZW compression.

I didn't suppose to replace the hard-coded PNG with BMP or any other format — my idea was to let the user/script request the desired format (maybe by putting a suffix into screenShotPrefix or just a separate parameter for the method).

10110111 commented 5 years ago

BTW, for animations, it is much easier to just capture and record the screen. Use Windows 10's Win-G key combination to open the Game menu and record into MP4 (beware, it also records the mouse cursor...). For other systems, there are 3rd-party screen recorders.

No, it's not when you need reproducibility. I'm working on a change in a Stellarium visual and need to be able to e.g. see old and new version side-by-side (like here). In this case exactly matching frames are a must, and you can't achieve this with an external screencasting software.

gzotti commented 5 years ago

Ah I see. I suspected yesterday what you are doing (from your post to that other github project), this looks great -- looking forward to seeing this side-to-side with my timelapse photos! But please make it switchable (old/new) in the config dialog. And if the new model allows (no time to go into details), think of conditions on other planets (Mars?). I have a stuck branch gz_AtmosphereTweaks that allows playing with the unintuitive Preetham parameters in the GUI. It's at least instructive about that model. You could allow many user tweaks as well (with a reset to useful defaults!).

Yes I understand you want BMP in addition to, and not replacing PNG. I just said, if we open up formats, we can likewise add JPG to the set. Obviously, this is not for screenshotPrefix but another parameter (defaulting to PNG), and yet another combobox in the GUI will not kill us.

10110111 commented 5 years ago

if we open up formats, we can likewise add JPG to the set

Maybe simply let the user save into any format supported for writing by QImage, instead of artificially limiting the set of allowed formats? The list can be found in Qt docs.

gzotti commented 5 years ago

No problem with that, although I don't know how many Windows users (or also on other platforms!) would like to create XBM? Anyway, if it's just an extension to add, we can do it.

gzotti commented 5 years ago

Almost there, supporting whatever Qt offers. However it seems wbmp format is broken, and I am not sure if "Apple Icon" (ICNS) or "cur" (cursor definition?) formats are useful. ICO can be used as thumbnail. @alex-w , @10110111 , opinions?

alex-w commented 5 years ago

I think PNG, JPG and BMP is enough here.

10110111 commented 5 years ago

However it seems wbmp format is broken

Do you mean "Windows BMP" or something unusual? And how exactly "broken"? I've successfully used BMP format (as described in the OP) to generate series of 960 screenshots very fast, and the files were OK.

and I am not sure if "Apple Icon" (ICNS) or "cur" (cursor definition?) formats are useful

Hmm, Qt docs don't mention them. Are they really supported on every platform? Anyway, cursor formats seem useless, and icons usually have very small sizes.

Anyway, if there are indeed so many problems with the "what Qt supports" way, I agree that PNG, JPG & BMP is a good enough set.

gzotti commented 5 years ago

My current implementation asks QImageWriter what it supports (this may be platform dependent), and meanwhile excludes WBMP (IrfanView fails to open; broken? irrelevant.), CUR (like ICO?) and ICNS (Apple Icon? I have no program to open that. Allow on Mac?). The others have their merit, even various PGM, XPM, etc. PBM as 1-bit dithered B/W for faxes or cheap printing, ...

WBMP was a bitmap format for early mobile phones, used for WAP protocol, but largely obsolete. BMP works. I still must write documentation, will submit later.

10110111 commented 5 years ago

OK, it seems I was too naive thinking that the set of supported images is a trivial matter... Maybe indeed better limit to something which at least makes sense.

10110111 commented 5 years ago

It seems there's still no scripting API for this, or am I wrong?

gzotti commented 5 years ago

Ah, maybe not for setting type. I assume you do that in the Config panel. Or do you require this scriptable?

gzotti commented 5 years ago

Hm, I could change the core.screenshot() so that a file ending would be split off and used. Hopefully by tomorrow.

10110111 commented 5 years ago

I was just assuming I wasn't looking in the right place, didn't expect there'll be no scripting API for this. But if I can set this option so that it's saved, then it's OK for me. Just tried, this works. Thanks.

alex-w commented 5 years ago

@gzotti enhancement the core.screenshot() is good place for new feature.

10110111 commented 5 years ago

Wouldn't changing the interface of core.screenshot() interfere with auto-counting? Or is it supposed to be like my-new-file.jpg → {my-new-file00000.jpg, my-new-file00001.jpg, ...}?

gzotti commented 5 years ago

It should be possible to provide a filename, chop off the ending, and insert the running number. If there is no 3-4 letter ending (split at "."), use currently set type.

gzotti commented 5 years ago

OK, no chopping, just added another (optional) component.

 core.screenshot("screen-", true, "", false, "webp");
10110111 commented 5 years ago

Confirming that it works, thanks.