3. 撤销

Almost anything you do to an image in GIMP can be undone. You can undo the most recent action by choosing EditUndo from the main menu, but this is done so frequently that you really should memorize the keyboard shortcut, Ctrl+Z.

Undoing can itself be undone. After having undone an action, you can redo it by choosing EditRedo from the main menu, or use the keyboard shortcut, Ctrl+Y. It is often helpful to judge the effect of an action by repeatedly undoing and redoing it. This is usually very quick, and does not consume any extra resources or alter the undo history, so there is never any harm in it.

[小心] 小心

如果您撤消一个或多个操作,然后以除使用撤消或重做以外的任何方式对图像进行操作,则将无法再重做这些操作:它们将永远丢失。如果它给您带来问题,解决方案是复制图像,然后在副本上进行测试。(别测试原图,因为当你复制图像时,不会复制撤销/重做历史。)

如果您经常发现自己一次撤消和重做许多步骤,使用撤消历史对话框可能更方便,这是 一个可停靠的对话框,显示撤消历史中每点的小草图,允许您返回或单击前进到该点。

撤消是在特定于图像的基础上执行的:“撤消历史”是图像的组成部分之一。为此,GIMP会为每个图像分配一定数量的内存。您可以使用首选项对话框的系统资源页面自定义你的偏好设置以增加或减少数量。有两个重要的变量:最小撤消级别数,无论它们消耗多少内存,GIMP都将保持该数量;以及最大撤消内存数,超过该数量, GIMP将开始从撤消历史记录中删除最旧的项目。

[注意] 注意

即使撤消历史是图像的一个组成部分,当您使用GIMP的原生 XCF 格式(它保留了所有其他图像属性)保存图像时,它也不会被保存。当图像重新打开时,它会有一个空的撤消历史。

GIMP的撤销实现相当复杂。许多操作只需要很少的撤消内存(例如,更改图层的可见性),因此您可以在它们退出撤消历史记录之前执行较长的操作序列。某些操作(例如更改图层可见性)被压缩,因此连续执行多次这些操作只会在撤消历史记录中生成一个点。但是,还有其他操作可能会消耗大量撤消内存。大多数滤镜是由插件实现的,所以GIMPcore 没有有效的方法来知道发生了什么变化。因此,除非在操作前后记住受影响层的全部内容,否则无法实现撤消。在它们退出撤消历史记录之前,您可能只能执行一些此类操作。

3.1. 不可撤销的操作

Most actions that alter an image can be undone. Actions that do not alter the image generally cannot be undone. Examples include saving the image to a file, duplicating the image, copying part of the image to the clipboard, etc. It also includes most actions that affect the image display without altering the underlying image data. The most important example is zooming. There are, however, exceptions: toggling Quick Mask on or off can be undone, even though it does not alter the image data.

有一些重要的操作会改变图像但无法撤消:

关闭图像

撤消历史是图像的一个组成部分,因此当图像关闭并释放其所有资源时,撤消历史就消失了。因此,除非图像自上次保存后没有被修改,否则GIMP总是会要求您确认是否确实要关闭该图像。

恢复图像

恢复 表示从文件中重新加载图像。GIMP实际上是通过关闭图像并创建新图像来实现的,因此撤消历史会丢失。因此,如果图像不干净,GIMP会要求您确认是否确实要还原图像。

操作的片断

有些工具需要您在它们生效之前执行一系列复杂的操作,但只允许您撤消整个操作而不是单个元素。例如,智能剪刀要求您通过单击图像中的多个点来创建闭合路径,然后在路径内部单击以创建选区。您无法撤消单个点击:完成后撤消会将您带回起点。再例如,当您使用文本工具时,您无法撤消单个字母、字体更改等:完成后撤消会删除新创建的文本层。

Filters, and other actions performed by plug-ins or scripts, can be undone just like actions implemented by the GIMP core, but this requires them to make correct use of GIMP's Undo functions. If the code is not correct, a plug-in can potentially corrupt the Undo History, so that not only the plug-in but also previous actions can no longer properly be undone. The plug-ins and scripts distributed with GIMP are all believed to be set up correctly, but obviously no guarantees can be given for plug-ins you obtain from other sources. Also, even if the code is correct, canceling a plug-in while it is running may corrupt the Undo History, so it is best to avoid this unless you have accidentally done something whose consequences are going to be very harmful.