Page 1 of 1
JPEG quality setting syntax
Posted: Tue Oct 15, 2019 2:38 pm
by amyren
I use this command to save the screen as an image file.
The docs mention that default quality setting is 90, so I want to reduce this to create smaller files.
But there is no example in the docs using the quality setting, so I am not sure how to set it.
I did try some variants, but either it was ignored, or it gave me an error.
So what is the correct way to enter it? The example below does not affect the filesize, so it must be the wrong way.
If there is a rule of thumb to know how arguments in Hollywood commands should be entered, it would be nice to learn...
Code: Select all
SaveSnapshot("test.jpg", #IMGFMT_JPEG, Quality = 50)
Re: JPEG quality setting syntax
Posted: Tue Oct 15, 2019 3:48 pm
by sinisrus
Dither, Colors and Quality is on table, add this => {}
Code: Select all
SaveSnapshot("test.jpg", #IMGFMT_JPEG, {Quality = 50})
Re: JPEG quality setting syntax
Posted: Tue Oct 15, 2019 9:40 pm
by amyren
Thanks for the suggestion, but I think I did try that combination already.
That line will give this error output:
Error in line 1749 (test.hws): Number expected in argument 3!
Re: JPEG quality setting syntax
Posted: Tue Oct 15, 2019 11:17 pm
by Tipsi
The function
SaveSnapshot() have 4 arguments:
SaveSnapshot(f$[, mode, fmt, table])
mode: "This can be #SNAPWINDOW, which means that theHollywood window will be grabbed (with borders), #SNAPDISPLAY, which means thatonly the display’s contents will be grabbed or #SNAPDESKTOP, which means that thecomplete host screen will be grabbed."
Code: Select all
SaveSnapshot("test.jpg", #SNAPDESKTOP, #IMGFMT_JPEG, {Quality = 50})
Griessli
Tipsi
Re: JPEG quality setting syntax
Posted: Wed Oct 16, 2019 8:34 am
by amyren
Thank you.
When I saw your comment my initial thought was that it probably wouldn't work either.
Since the #SNAPWINDOW argument is optional and have a default value I thought it should not make any difference, and also the third argument
worked without the second argumement. And that error message "number expected" did not make it any easier to understand.
I wish it was possible to have some more examples included in the docs, covering a more arguments for each command.
But it did work now, so thanks again.
Re: JPEG quality setting syntax
Posted: Wed Oct 16, 2019 11:38 am
by jPV
amyren wrote: ↑Wed Oct 16, 2019 8:34 am
Since the #SNAPWINDOW argument is optional and have a default value I thought it should not make any difference, and also the third argument
worked without the second argumement.
When giving these optional arguments, you can't skip any of them in the middle. If you want to give the third argument, you must provide the second argument too. How could Hollywood know which one of them you try to give otherwise? It's pretty obvious if you try to play around with arguments on your own functions, for example. Only exception is that you can skip optional arguments from the end, but otherwise they must be given in the correct order.
If a third argument worked without a second argument, then it was just pure luck and the argument was correct type and accepted by chance.
And that error message "number expected" did not make it any easier to understand.
It tells that an argument was expected to be a number, but you tried to give it something else (a table). If you remember that constants (named starting with #) are always numbers or strings, and I think all built-in constants in Hollywood are numbers, it should be quite explanatory then.