Page 1 of 1

Default file format for screenshots

PostPosted: Sun Mar 06, 2016 16:32
by rubberduck
The file format for screenshots is png now, but it has the disadvantage of a bigger file size.
This could be changed to jpg, (this is better for posting images on the forum too)
There could be setting for a default file format, if you want to use png instead.

Re: Default file format for screenshots

PostPosted: Sun Mar 06, 2016 19:00
by MineYoshi
i don't know why the question, the format of screenshots is png and everyone don't say nothing about it because is normal, png is a good format.

And what happens with the image size,in really that means a better definition and quality!

Re: Default file format for screenshots

PostPosted: Mon Mar 07, 2016 07:19
by firefox
jpg files have a quality issue.
every time you edit and save them, the quality will decrease.
png files will stay the same.

i don't know the exact details, but jpg images don't support all the stuff that the png format has, so the image is downgraded and simplified when saving it as a jpg. this process will repeat with every save, reducing the image quality.

Re: Default file format for screenshots

PostPosted: Mon Mar 07, 2016 08:39
by oleastre
If you want some background, jpeg is a lossy format; it means that to achieve better compression, it removes some information from your image, based on the fact that human eye does not react to every colors in the same way. That kind of compression can create "artifacts" in the image, that results in some visible blocks. And jpeg is quite bad with large patch of the same color.

On the other side, png is a lossless format, it encodes every details of your image, in the trade of file size. But png is quite good at it's job.

If you want to compare, I did a screenshot in minetest and saved it two times, one in png and one in jpeg (with quite low quality). Then I enlarged both and here is the result:
PNG: Image

JPEG: Image

So, for a game like minetest, you would be quite disappointed if the default image format would be jpg; no way to get a good quality screenshot.
And so, yes png is the best format in that case; and supporting another export format means adding options (format, compression quality), another library as dependency, and code to maintain...

And probably at the end, you will open the screenshot before posting it to a web site; either to resize it or to add some watermark or ...

My opinion is that it's probably better to focus on other part of the engine before the screenshot format :) (but who knows, if you come with code and a pull request...)

Re: Default file format for screenshots

PostPosted: Mon Mar 07, 2016 11:23
by Morn76
The JPEG format isn't inherently lossy, it entirely depends on the quality setting when saving.

MT could save as 100%-quality JPEG by default. That would basically be the same as PNG, i.e. there would be no JPEG artifacting.

If JPEG quality were a configurable parameter in minetest.conf, users could set it to e.g. 80 or 85% to get smaller JPEG files for the forums. That would save one conversion step from PNG to JPEG.

Re: Default file format for screenshots

PostPosted: Mon Mar 07, 2016 11:38
by oleastre
Just do a simple test: save a minetest screenshot as a jpg file with quality set to 100%; open it in your favorite image editor alongside the png version.
Put the two images in different layers and do a difference between the two.
After that, just boost a little bit the brightness to see something.

Here is the same screenshot where I applied that method:
Image

Jpeg does a Fourier transform of the image, and encodes rgb values as luminance (luminosity) and chrominance (color), with more details for luminance (as the human eye is more sensible to that) than for chrominance. All of this introduces loss of information and approximations, even at 100% quality.

So for the best quality, you need a true lossless format; ie png.

Re: Default file format for screenshots

PostPosted: Mon Mar 07, 2016 12:59
by Morn76
Without a scale that tells us what the colors mean, that image does not tell us the absolute size of the error introduced by saving as 100% JPEG.

If e.g. errors are ±1 in R, G, B each on a scale of 0 to 255, then I think it's close enough to call it lossless for our purposes.

The question is whether the naked eye can see a difference. Subtracting in Gimp and boosting contrast of the difference is not the same as the capabilities of the human eye.

Re: Default file format for screenshots

PostPosted: Mon Mar 07, 2016 13:21
by Linuxdirk
Morn76 wrote:Without a scale that tells us what the colors mean, that image does not tell us the absolute size of the error introduced by saving as 100% JPEG.

But in fact it shows that “100% quality JPEG” is still lossy. It doesn’t matter ow much information you lose … you just lose information when using JPEG.

For publishing images JPEG is currently the best format available because it’s supported by all relevant browsers withoiut any problems and can be viewed using almost any relevant operating system available.

For unprocessed material grabbed from the source there should always a lossless format should being used. An established lossless format for images is PNG – You can crop, scale and edit it as you want without having a lower quality to start with than the source provides. Export it as JPEG and publish it as you want.

Re: Default file format for screenshots

PostPosted: Mon Mar 07, 2016 13:48
by twoelk
Fact is JPG deletes all information and replaces it by calculating something the eye thinks looks similar enough to normally not notice any difference. Even with quality set to 100% the original information is destroyed and replaced by a detailed calculated version. PNG keeps every pixel information and is therefore much more usefull if you need to edit the picture. Keep in mind that changing the size of a picture is also editing the content. From a JPG there is no way back to the original information. JPG's do not store single pixel information - that is the reason that a JPG picture may look different in various programs and on different platforms. How a JPG is presented is calculated from the saved file and not read.

Simplified to the extreme you may think of JPG'ng a picture as splitting the picture in tiles of say 9 by 9 pixels. Next you store the values of two pixels on opposing corners and delete the rest. You now store the information which is only about a third of the original. When you open the picture you set up the tiles with the two pixels as extreme values and calculate a transition between the two. You then fill the remaining pixels with the calculated values. Of course it is a little more complicated than that but you might get an idea what "lossy" format means. For example JPG is extremely bad with sharp high contrast borders such as in black text on white background.

JPG is good enough for photos but not really good for professionals who rather use PNG or even TIFF. For pixel drawings, pictures with large areas of the same color, pixel exact borders or limited colors PNG or even GIF is by far the better choice.

Re: Default file format for screenshots

PostPosted: Mon Mar 07, 2016 14:19
by Morn76
Well, I'm not personally against supporting multiple screenshot file formats, e.g. PNG and JPG, preferably the latter with a user-selectable quality setting. Personally I will switch to JPG as soon as the MT git version supports it, because right now both the original PNGs and converted JPGs are hogging hard disk space without a real benefit.

That said, even valuable scientific data today is routinely converted to and archived using slightly compressed/lossy formats, e.g. GRIB, JPEG 2000, etc. So I think your are making a mountain out of a molehill error that is on the same order as a rounding error (and probably mostly _is_ a rounding error from the forward and inverse Fourier transform.) I certainly understand the slight benefit of PNG, but I was also considering the benefit of keeping MT's code base and config options as simple as possible.

Re: Default file format for screenshots

PostPosted: Mon Mar 07, 2016 15:57
by Linuxdirk
Morn76 wrote:… but I was also considering the benefit of keeping MT's code base and config options as simple as possible.

… and that means: Use the best supported available lossless image format for screenshots only and let the users process the images manually instead of adding multiple export formats.

Re: Default file format for screenshots

PostPosted: Mon Mar 07, 2016 19:06
by rubberduck
Ok, i think now, that is a good idea. So this feature is not needed anymore.

Re: Default file format for screenshots

PostPosted: Mon Mar 07, 2016 22:11
by kaeza
https://github.com/minetest/minetest/pull/3826

Trivial change, everybody's happy.

Re: Default file format for screenshots

PostPosted: Mon Mar 07, 2016 22:43
by MineYoshi
Well i think this is clear now, Minetest have PNG format screenshots and is better don't change it to JPEG because becomes a lossy format, if you upload it, his quality decrease!

So i think better left MT screenshot system how is, and better go and do other thing instead!

Re: Default file format for screenshots

PostPosted: Sun Mar 13, 2016 13:04
by kaeza
FWIW, Option is now in core and will be available in the upcoming release.

Enjoy.

Re: Default file format for screenshots

PostPosted: Sun Mar 13, 2016 23:19
by MineYoshi
...

I will see how works that out...

Re: Default file format for screenshots

PostPosted: Thu Mar 17, 2016 02:32
by Sokomine
kaeza wrote:FWIW, Option is now in core and will be available in the upcoming release.

Thank you! A tiny change but a great help - at least for me. The screenshots now take up far less disk space. And: Sending them over the internet takes far less time. All these huge screenshots around here (which nobody ever scales down to a reasonable size) take a long time to load with a not-so-fast connection. I've given up taking a look at Jordachs blender renders because loading the thread takes eternity :-(
The vast majority of MT screenshots will be fine with jpeg instead of png format. Savefiles of entire buildings are easily by a factor of 10 smaller than the 2d screenshot showing the building. That will continue to remain so with jpeg, but at least the screenshots can be a bit smaller now.

Re: Default file format for screenshots

PostPosted: Thu Mar 17, 2016 03:16
by kaeza
MineYoshi wrote:...

I will see how works that out...

The default format is still PNG. Unless you specifically went look for the option, you wouldn't even know that JPEG, TGA, PCX, and PPM formats are available (JPEG even has a quality setting). So no loss if you don't care, but very convenient for those that prefer (waaaaay) smaller files to pixel-perfect quality (both for storage and transfer), but don't want to deal with converting images manually. Great convenience at the expense of trivial changes which have no effect whatsoever in terms of memory or CPU usage? I would take that any day.

Sokomine wrote:Thank you! A tiny change but a great help - at least for me. The screenshots now take up far less disk space. And: Sending them over the internet takes far less time. All these huge screenshots around here (which nobody ever scales down to a reasonable size) take a long time to load with a not-so-fast connection. I've given up taking a look at Jordachs blender renders because loading the thread takes eternity :-(
The vast majority of MT screenshots will be fine with jpeg instead of png format. [...]

You are quite welcome, and count me in too. :)

Re: Default file format for screenshots

PostPosted: Thu Mar 17, 2016 19:39
by MineYoshi
Wow....