Specify image quality when "saving as" in standalone viewer

In the standalone viewer, I use buttons for lossless rotation, e.g. Show VIEWERCMD=rotate,+90.

After performing the rotations, I would simply like to click the Save button to make the changes permanent. The default Save button uses the code Show VIEWERCMD=save. However, after making the rotations in the viewer, this Save button is disabled. I notice it becomes active when you want to save crop changes, but not rotation changes.

To get around this limitation, I created a custom Save button for the viewer with the following code:

Option Explicit
Function OnClick(ByRef clickData)
ClickData.Func.Command.RunCommand "Show VIEWERCMD " & """" & "saveas," & DOpus.viewers.lastactive.current.realpath & """"
End Function

This works to save the rotations to the file without prompting for a new name (it simply overwrites the original). However, there doesn't seem to be a way to specify the image quality when using Show VIEWERCMD saveas.

What is the default quality that is being used when saving with the button above?

Also, for the DOpus developers, if there's no way to specify the image quality when using the Show VIEWERCMD saveas command, would it be possible to add this feature in a future version?


If you use Image ROTATE instead, you won't have to worry about quality at all.

Thanks for the suggestion. So let's say I'm in the standalone viewer and I have a button like this on its toolbar:

Show VIEWERCMD=refresh

When clicking the above button, will the rotation cause any quality loss? I was under the impression that the Show VIEWERCMD ROTATE command from the standalone viewer was somehow different than the Image command because the rotation doesn't actually change the file until it's saved. Is that not the case?

The Image ROTATE command will do lossless JPEG rotation where possible (as long as you don't add the NOLOSSLESS argument, and as long as the JPEG doesn't have unusual dimensions which prevent lossless rotation).

Show VIEWERCMD ROTATE just rotates the image on the screen; it doesn't touch the file on disk.

Thanks for the explanation Leo. Do you know what the default quality of a saved jpeg is if I use Show VIEWERCMD "saveas,c:\image.jpg" ?

I'm also wondering if there's anywhere in DOpus that I can set a default jpeg quality which would be used in cases where a button command doesn't specify quality, like the one above.

Default JPEG quality of Show VIEWERCMD "saveas... is whatever was last used when you saved an image from the viewer (without specifying a filename in the command). It's set at the bottom of the Save As dialog:

If that value has never been changed (or you've never saved an image in that way before), the default quality is 90.

(n.b. Quality values in one program may not be directly comparable to those in another, since they may be using different jpeg libraries or options.)

Great, thanks for confirming Leo. I guess I'll stick with my original workaround. It would be nice if a QUALITY option, and perhaps even a REPLACE/OVERWRITE option, were added to the Show VIEWERCMD save/saveas commands, something like:

Show VIEWERCMD "saveas,c:\image.jpg, QUALITY=100 REPLACE".

But for now, I guess my workaround will suffice: set the quality in the viewer Save As dialog once (effectively making it the default quality), and then use the script button at the top of this post to save all the changes in one click.

The reason why I'm opting for this rather than the Image command is because it's nice to mess around with pictures in your image viewer/editor without causing any degradation (which the Image command may do under certain circumstances), and then once you've settled on the changes you'd like to make, simply save them with one click without needing to browse for a save location and confirming a file overwrite.

If quality is your concern, you should aim for lossless rotation, which means using the Image command (and then the viewer refresh command, as you were doing). You don't want to be recompressing the JPEG data at all just to rotate it. That can be set up as a button in the viewer.

I see. So once a jpeg file is saved from the viewer, some recompression is occurring on the JPEG data, which may potentially cause some quality loss.

In that case, the Image command sounds like a better option. Thanks for clarifying.