JPEG quality setting syntax

Find quick help here to get you started with Hollywood
Post Reply
amyren
Posts: 352
Joined: Thu May 02, 2019 11:53 am

JPEG quality setting syntax

Post 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)
sinisrus
Posts: 347
Joined: Tue Apr 21, 2015 5:43 pm

Re: JPEG quality setting syntax

Post by sinisrus »

Dither, Colors and Quality is on table, add this => {}

Code: Select all

SaveSnapshot("test.jpg", #IMGFMT_JPEG, {Quality = 50})
amyren
Posts: 352
Joined: Thu May 02, 2019 11:53 am

Re: JPEG quality setting syntax

Post 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!
Tipsi
Posts: 21
Joined: Sun Feb 14, 2010 6:06 pm
Location: Switzerland

Re: JPEG quality setting syntax

Post 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
amyren
Posts: 352
Joined: Thu May 02, 2019 11:53 am

Re: JPEG quality setting syntax

Post 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.
User avatar
jPV
Posts: 603
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

Re: JPEG quality setting syntax

Post 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.
Post Reply