Bug 100344 - UNO command to "Restore to Original"
Summary: UNO command to "Restore to Original"
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: UI (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
: 107262 (view as bug list)
Depends on:
Blocks: UNO-Command-New Writer-Images
  Show dependency treegraph
 
Reported: 2016-06-12 17:31 UTC by Luke
Modified: 2023-04-21 17:19 UTC (History)
8 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Luke 2016-06-12 17:31:21 UTC
When working with images, it’s very useful to have a “Reset” button to restore your image to its original condition.  Currently we can only restore resized images with “Original Size”.  A much more useful command would allow you to completely restore an inserted image to its original state. This would undo everything including resizing, rotating, scaling, cropping and framing with lines. 

Unless someone can come up with a compelling, common use-case, I see no reason for “Reset Image” to not replace “Original Size” in the context menu.
Comment 1 Joel Madero 2016-06-13 00:30:57 UTC
This is really two things in one:
1) make an entirely new uno command;
2) Replace the reset image with said uno command

I have no opinion as to #2 (UX needs to deal with that). First point makes sense. Marking as new and setting as an enhancement
Comment 2 Gülşah Köse 2016-06-14 08:07:08 UTC
Hi Luke,
I think Original Size shouldn't be replaced with Reset Image. It is good idea. I've started to work on. Thank you for reporting and letting me know.
Comment 3 Gülşah Köse 2016-06-29 09:48:46 UTC
Still working on and i've sent a patch for it:
https://gerrit.libreoffice.org/26757
Comment 4 Luke 2016-07-02 21:37:39 UTC
How can I test this after applying the patch?  Since this is more useful superset of uno:OriginalSize, could you remap it to use your new command for testing and evaluation? If we don’t a replace the "Original Size" context menu option, we should create a “Reset” button in the sidebar.
Comment 5 Björn Michaelsen 2016-07-18 15:40:50 UTC
This needs a lot of discussion on what is intended and if we can actually reasonably provide it. See my comment on patchset 4 at https://gerrit.libreoffice.org/#/c/26757/4 ... => NEEDINFO
Comment 6 Luke 2016-07-18 20:22:24 UTC
> I dont think we want to inflate files by storing both the original and the modified images (people might also find it surprising that their original image contents are "leaked"). 


The purpose of this function is to restore an inserted image by resetting all attributes like rotations, cropping, scaling, etc back to their default values. So we shouldn't have store a copy of the original or use the undo stack. Currently you can manually undo a cropping after saving, so this function should also be able to work after a save+close(the original data must be stored somewhere). After rotating an image, you can manually, rotate it back to 0 degrees, so this reset function should also be able to do this.

Other office suites like WPS Office and MS Office have an image reset function. So a user coming from other suites trying to use "Original Size" to fix a cropping error, ends up thinking our software is buggy. 


In the cases where our image manipulation is destructive, like rotating in writer, I'd rather see them made non-destructive(see Bug 73797) and have their rotation values reset to default. Impress and Calc should just be able to set the rotation angle back to their default value of 0.

Armin, 
This is your area of expertise. Do you have any feedback?
Comment 7 Björn Michaelsen 2016-07-19 14:15:37 UTC
(In reply to Luke from comment #6)
> The purpose of this function is to restore an inserted image by resetting
> all attributes like rotations, cropping, scaling, etc back to their default
> values.

Hmm, in a limited way that might work. That would mean to reset the AttrSet (e.g. the stuff that happens at grfsh.cxx:651):

 GetShell().SetAttrSet( aGrfSet );

> So we shouldn't have store a copy of the original

Yes (mostly).

> or use the undo stack

No. This need to be undoable. Otherwise, if you undo over a "reset image", the earlier steps will assume a different state than there is. So undo of the attribute reset still has to be implemented.

> In the cases where our image manipulation is destructive, like rotating in
> writer, I'd rather see them made non-destructive(see Bug 73797) and have
> their rotation values reset to default. Impress and Calc should just be able
> to set the rotation angle back to their default value of 0.

This is not really possible. E.g. there is "compress image" -- making that non-destructive totally kills the usecase there. Also "make manipulation non-destuctive" might require to keep additional state (the pre-manipulation image state) and keep it over save-reload circles -- thus possibly requiring file-format extension. It needs careful examination if that is worth it.
Comment 8 Björn Michaelsen 2016-07-19 14:31:29 UTC
(In reply to Björn Michaelsen from comment #7)
> This is not really possible. E.g. there is "compress image" -- making that
> non-destructive totally kills the usecase there. Also "make manipulation
> non-destuctive" might require to keep additional state (the pre-manipulation
> image state) and keep it over save-reload circles -- thus possibly requiring
> file-format extension. It needs careful examination if that is worth it.

So, to further elaborate:
- "reset image" could reset all non-destructive changes to an image
- "reset image" needs to be undoable to keep the UNDO stack consistent (and ultimately: to prevent it from crashing)[1]
- "reset image" doesnt reset destructive changes like "compress image"
- thus destructive changes like "compress image" loose the original state on safe and reload into a new session (you are out of luck then)
- in a running session, one should be able to undo back over them though

Seeing this, this likely also needs explicit documentation for end users.


[1] This shouldnt be too hard: Just store the pre-change attribute set in an undo object.
Comment 9 Armin Le Grand (allotropia) 2016-07-22 08:25:14 UTC
I would implement 'reset' as setting all attributes like transformation (rot translate shear scale (includes mirror)), cropping to 'default' -> not set.

The image itself will only be touched with the 'compression' options when used at save time, that will not be resettable and should not be -> having a copy of the original would kill the compression feature and it's intentions.

For the size at reset: Each image has a default size in a way, may it be pixel size and DPI. This is already used at inserting image as new and the only value that needs not only be resetted but new calculated. It is e.g. at original insert time scaled to match maximal sizes defined by PageSizes, so that big images do not/cannot hide everything which would not be what you expect.

For the position: At orig inserting this is different in all apps (canter on page in Draw/Impress, cursor pos in writer, cell in calc) and shuld probably only be changed on reset when the size has to be corrected in the sense mentined above.

All these changes can be packed in an undo action, should be possible.
Comment 10 QA Administrators 2017-03-01 10:41:15 UTC Comment hidden (obsolete)
Comment 11 Luke 2017-03-01 18:44:15 UTC
Still to way to reset image attributes in 
Version: 5.4.0.0.alpha0+
Build ID: bd7dd48189e5ff7f62e16e53f0a02d1068583108
Comment 12 Yousuf Philips (jay) (retired) 2017-04-19 17:45:43 UTC
*** Bug 107262 has been marked as a duplicate of this bug. ***
Comment 13 Yousuf Philips (jay) (retired) 2017-04-19 18:03:09 UTC
So what we need is a few image reset UNO commands and ideally it should work in all modules, which unfortunately .uno:OriginalSize doenst (bug 107275).

.uno:ImageResetStyle - This removes styling applied to an image like brightness, contrast, transparency, color mode, rgb tinting, gamma, borders, shadow, area fill, etc.

.uno:ImageResetSize - This removes crop, resets rotation and flip, and sets image size to 100%

.uno:ImageResetStyleAndSize - .uno:ImageResetStyle plus .uno:ImageResetSize
Comment 14 Regina Henschel 2017-04-19 19:03:17 UTC
And the help for such new commands should list all actions, which cannot be reset, to avoid false expectations. And help should describe restrictions e.g. by page size.