JPEG quality setting syntax

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

JPEG quality setting syntax

Post by amyren » Tue Oct 15, 2019 2:38 pm

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: 263
Joined: Tue Apr 21, 2015 5:43 pm

Re: JPEG quality setting syntax

Post by sinisrus » Tue Oct 15, 2019 3:48 pm

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

Code: Select all

SaveSnapshot("test.jpg", #IMGFMT_JPEG, {Quality = 50})

amyren
Posts: 87
Joined: Thu May 02, 2019 11:53 am

Re: JPEG quality setting syntax

Post by amyren » Tue Oct 15, 2019 9:40 pm

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: 16
Joined: Sun Feb 14, 2010 6:06 pm

Re: JPEG quality setting syntax

Post by Tipsi » Tue Oct 15, 2019 11:17 pm

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: 87
Joined: Thu May 02, 2019 11:53 am

Re: JPEG quality setting syntax

Post by amyren » Wed Oct 16, 2019 8:34 am

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: 281
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

Re: JPEG quality setting syntax

Post by jPV » Wed Oct 16, 2019 11:38 am

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