第 6 章 从 GIMP 中获取图像

目录

1. 文件
1.1. 保存/导出图像
1.2. 文件格式
2. 为网络准备图像
2.1. 具有最佳尺寸/质量比的图像
2.2. 进一步缩小文件大小
2.3. 保存带有透明度的图像

1. 文件

GIMP is capable of reading and writing a large variety of graphics file formats. With the exception of GIMP's native XCF file format, file handling is done by plug-ins. This makes it relatively easy to extend GIMP to support new file types when the need arises.

1.1. 保存/导出图像

[注意] 注意

When you opened an image in older GIMP releases, let's say a JPG or PNG, the image kept its format and was saved in the same format by using Save. Since GIMP 2.8, all images are imported into GIMP's own XCF format, as a new project.

For example, a sunflower.png image will be loaded as *[sunflower] (imported)-1.0 (indexed color, 1 layer). The leading asterisk indicates that this file has been changed. This image can be saved as sunflower.xcf by using the Save command. If you need your image in another format, you should use the Export command.

When you are finished working with an image, you will save the results. In fact, it is often a good idea to save at intermediate stages too. GIMP is a pretty robust program, but on rare occasions crashes have happened.

GIMP's native format XCF is special. It is the only format that can store everything about an image (with the exception of undo information). This is the reason that saving can only be done in this format. It makes the XCF format especially suited for storing intermediate results, and for saving images to be re-opened later in GIMP.

XCF files are not readable by most other programs that display images. Once you have finished editing your image, you can export it to the format of your choice. GIMP supports a wide range of formats. Most file formats that can be imported, can also be used for exporting.

1.2. 文件格式

There are several commands for saving and exporting images. They are listed in the section covering the File Menu. More information on how to use them can be found there.

GIMP 允许您以多种格式导出您创建的图像。重要的是要认识到,能够保存图像中所有信息(包括图层、透明度等)的唯一格式是 GIMP 的原生 XCF 格式。其他所有格式都会保留一些图像属性并丢失其他图像属性。取决于您了解您选择的格式的功能。

导出图像不会修改图像本身,因此导出不会丢失任何内容。请参阅导出文件

[注意] 注意

当您关闭图像(可能是通过退出 GIMP)时,如果图像是“脏的”,您会收到警告;也就是说,如果它在进行了更改,没有随后保存的情况下(星号在图像名称前面)。

图 6.1. 关闭警告

关闭警告

Saving an image in GIMP's native format XCF will cause the image to be considered "not dirty". On the contrary, exporting an image will not change it to "not dirty", because GIMP can't know for sure that no image information will be lost.

1.2.1. 将图像导出为 GIF

图 6.2. GIF导出对话框

GIF导出对话框

[警告] 警告

GIF 文件格式不支持某些基本图像属性,例如打印分辨率。如果您关心这些属性,请使用不同的文件格式,例如 PNG。

GIF 选项
交错

勾选交错允许网页上的图像在下载时逐渐显示。渐进式图像显示在连接速度较慢的情况下很有用,因为您可以停止不感兴趣的图像;随着我们更快的连接速度,交错在今天的使用较少。

GIF注释

GIF 注释仅支持 7 位 ASCII 字符。如果您使用 7 位 ASCII 字符集之外的字符,GIMP将导出没有注释的图像,然后通知您注释未保存。

GIF 动画选项
反复循环

勾选此选项后,动画将重复播放,直到您停止它为止。

未指明的帧之间的延时

如果之前未设置,您可以设置帧之间的延迟(以毫秒为单位)。在这种情况下,您可以修改图层对话框中的每个延迟。

未指明的帧处理

如果之前没有设置过,您可以设置如何叠加帧。您可以在三个选项中进行选择:

  • 我不关心:如果您的所有图层都是不透明的,您可以使用此选项。图层将覆盖下面的内容。

  • 累积图层(组合):显示新的帧时不会删除先前的帧。

  • 每图层一帧(替换):在显示新帧之前将删除先前的帧。

上面输入的延迟用于所有帧

不言自明。

上面输入的布置用于所有帧

不言自明。

1.2.2. 将图像导出为 HEIF/HEIC

HEIF 代表高效图像文件格式。也称为 HEIC 高效图像编码。

HEIF 图像中存储的信息量是相同大小的 JPEG 图像中存储的信息量的两倍,从而获得更好的质量。截至 2019 年 10 月,没有浏览器原生支持 HEIF。

更多信息见维基百科

图 6.3. HEIF/HEIC导出对话框

HEIF/HEIC导出对话框

这些选项是不言自明的。

1.2.3. 将图像导出为JPEG

JPEG 文件的扩展名通常为 .jpg、.JPG 或 .jpeg。它是一种使用非常广泛的格式,因为它非常有效地压缩图像,同时最大限度地减少图像质量的损失。没有其他格式可以接近达到相同级别的压缩。但是,它不支持透明或多图层。

图 6.4. JPEG导出对话框

JPEG导出对话框

JPEG 算法非常复杂,并且涉及大量令人眼花缭乱的选项,其含义超出了本文档的范围。除非您是 JPEG 专家,否则质量参数可能是您唯一需要调整的参数。

质量

当您以 JPEG 格式保存文件时,会显示一个对话框,允许您设置质量级别,范围从 0 到 100。不过,高于 95 的值通常没有用。默认质量 85 通常会产生出色的结果,但在许多情况下,可以将质量设置得显著降低,而不会明显降低图像质量。您可以通过 在 JPEG 对话框中勾选在图像窗口中显示预览来测试不同质量设置的效果 。

[注意] 注意

请注意,JPEG 质量级别的数字在不同的应用程序中具有不同的含义。在 GIMP 中以 80 质量级别进行保存不一定与在不同应用程序中以 80 质量级别进行保存相似。

使用原图像的品质设定

如果在加载图像时附加了特定的质量设置(或量化表),则此选项允许您使用它们而不是标准设置。

如果您只对图像进行了一些更改,那么重新使用相同的质量设置将为您提供与原始图像几乎相同的质量和文件大小。与使用不同质量设置会发生的情况相比,这将最大限度地减少量化步骤造成的损失。

如果质量设置在原始文件中并不比默认画质设置好,那么选项 从原始图像使用质量好的设置将可用,但是尚未启用。这可确保您始终至少获得默认设置中指定的最低质量。如果您没有对图像进行重大更改,并且希望使用与原始图像相同的质量来保存它,那么您可以通过启用此选项来实现。

在图像窗口中显示预览

勾选此选项会导致图像显示中显示质量(或任何其他 JPEG 参数)的每个更改。(这不会改变图像:当 JPEG 对话框关闭时,图像会恢复到其原始状态。)

保存元数据

如果您加载的图像具有 Exif、XMP、IPTC 元数据,它们将被保留;并且在导出为 JPEG 时,您可以保留或不保留它们。

保存缩略图,保存颜色配置文件

许多应用程序使用小缩略图作为快速可用的小预览图像。

注释

您可以编辑附加到您加载的图像的注释或编写新的注释。

高级选项

有关高级设置的一些信息:

优化

如果启用此选项,将使用熵编码参数的优化。结果通常是一个较小的文件,但需要更多的时间来生成。

平滑

JPG 压缩会产生伪影。通过使用此选项,您可以在保存时平滑图像,减少伪影。但是您的图像将变得有些模糊。

使用算术编码

Arithmetic encoding is a form of entropy encoding (a lossless data compression scheme) that, since GIMP-2.10 can be used in exporting as JPEG. Images using arithmetic encoding can be 5 - 10 % smaller. But older software may have trouble opening these images.

使用重新开始标记

图像文件可以包括允许图像作为片段加载的标记。如果在网页中加载图像时连接中断,加载可以从下一个标记恢复。

间距(MCU行)

JPEG 图像存储为一系列名为 MCU(最小编码单元)的压缩方形图块。您可以设置这些图块的大小(以像素为单位)。

渐进

启用此选项后,图像块按顺序存储在文件中,以便在慢速连接网络下载期间进行渐进式图像优化。JPG 的逐行选项与 GIF 的交错选项具有相同的目的。不幸的是,渐进选项会生成稍大的 JPG 文件(与没有渐进选项的情况相比)。

[注意] 注意

Beware that certain older TVs and photo frames (and maybe other devices) may not be able to show jpeg images that have been exported with the progressive setting enabled (which is the default).

二次采样

人眼对整个色谱的敏感度并不相同。压缩可以使用它来将眼睛认为非常接近的略有不同的颜色视为相同的颜色。有三种方法可用:

  • 1x1,1x1,1x1(最佳质量):通常称为 (4:4:4),这会产生最佳质量,保留边框和对比色,但压缩较少。

  • 2x1,1x1,1x1 (4:2:2):这是标准的子采样,通常在图像质量和文件大小之间提供良好的比例。然而,在某些情况下,不使用子采样 (4:4:4) 会显着提高图像质量;例如,当图像包含精细细节时,如在统一背景上的文本,或具有几乎平坦颜色的图像。

  • 1x2,1x1,1x1这个和(2x1,1x1,1x1)类似,但是色度采样是在水平方向而不是垂直方向;好像有人旋转了图像。

  • 2x2,1x1,1x1(最小文件):通常称为 (4:1:1),这会生成最小文件。这适合边缘较弱的图像,但往往会使颜色变性。

DCT 方法

DCT是离散余弦变换,是JPEG算法从空间域到频域的第一步。选项是浮点数整数 (默认值)和快速整数

  • 浮点数:浮点数方法比整数方法稍微准确一些,但要慢得多,除非您的机器具有非常快的浮点硬件。另请注意,浮点数方法的结果可能因机器而略有不同,而整数方法应在任何地方给出相同的结果。

  • 整数(默认):此方法比float快 ,但不那么准确。

  • 快速整数:快速整数方法远不如其他两种方法准确。

1.2.4. 将图像导出为PNG

图 6.5. 导出图像为PNG对话框

“导出图像为PNG”对话框

交错

勾选交错允许网页上的图像在下载时逐渐显示。渐进式图像显示在连接速度较慢的情况下很有用,因为您可以停止不感兴趣的图像;随着我们更快的连接速度,交错在今天的使用较少。

保存背景颜色

如果您的图像具有多个透明度级别,而互联网浏览器仅识别两个级别,将改用工具箱的背景颜色。

保存 Gamma

Gamma 校正是校正计算机如何解释颜色值的差异的能力。这会将伽马信息保存在 PNG 中,以反映显示器的当前伽马系数。然后,其他计算机上的查看者可以进行补偿以确保图像不会太暗或太亮。

保存图层位移

PNG 支持称为oFFs 块的偏移值 ,它提供位置数据。不幸的是,GIMP中的PNG偏移支持被破坏了,或者至少与其他应用程序不兼容,并且已经很长时间了。不要启用偏移,在保存之前让GIMP将图层压平,您将没有问题。

保存分辨率

保存图像分辨率,以 ppi(每英寸像素数)为单位。

保存创建时间

文件被保存的日期。

保存注释

您可以在图像属性中阅读此评论 。

保存透明像素的颜色值

选中此选项后,即使像素完全透明,也会保存颜色值。但这仅适用于单个图层,而不适用于合并的合成图层。当多图层图像导出为单图层文件格式时,GIMP无法保留透明像素中的颜色值。

像素格式

By default your PNG image is exported in a pixelformat that resembles the settings of your image in GIMP. This is usually what you want, but when you need a specific output format you can change this here to 8 or 16 bits per channel RGB or Grayscale, with or without alpha channel.

压缩级别

由于压缩不是有损的,因此使用小于 9 的压缩级别的唯一原因是在速度较慢的计算机上压缩文件需要太长时间。无需担心解压缩:无论压缩级别如何,它都一样快。

保存元数据

如果您加载的图像具有 Exif、XMP、IPTC 元数据,它们将被保留;并且在导出为 PNG 时,您可以保留或不保留它们。

保存默认值

单击以保存当前设置。稍后,您可以使用加载默认值来加载保存的设置。

[注意] 注意

PNG 格式支持索引图像。因此,使用较少的颜色会产生较小的文件;这对于创建网络图像特别有用;参见第 6.6 节 “Indexed mode”

计算机处理名为字节的8位块。一个字节允许 256 种颜色。将颜色数量减少到 256 以下是没有用的:无论如何都会使用一个字节并且文件大小不会更小。而且,这种PNG8 格式和GIF一样,只使用一位透明;只有两个透明度级别是可用的,透明或不透明。

1.2.5. 将图像导出为TIFF

图 6.6. TIFF导出对话框

TIFF导出对话框

压缩方式

此选项允许您指定用于压缩图像的算法。

  • None: is fast, and lossless, but the resulting file can be very large.

  • LZW: The image is compressed using the Lempel-Ziv-Welch algorithm, a lossless compression technique. This is efficient and fast. More information at [WKPD-LZW].

  • 压缩位(Pack Bits):是一种用于数据运行长度编码的快速、简单的压缩方案。Apple 在 Macintosh 计算机上发布 MacPaint 时引入了 PackBits 格式。PackBits 数据流由一字节的报头和数据组成。(来源:[WKPD-PACKBITS]

  • Deflate: is a lossless data compression algorithm that uses a combination of the LZ77 algorithm and Huffman coding. It is also used in Zip and Gzip files and PNG images. Source: [WKPD-DEFLATE].

  • JPEG: is a very good compression algorithm but lossy. This is the same compression as used in JPEG images. Since it is lossy, you should not use this when image quality is important. This compression can not be used when your image is in indexed mode.

  • CCITT Group 3 fax and CCITT Group 4 fax are black and white formats developed to transfer images by FAX.

    [注意] 注意

    These two compression modes can only be selected, if the image is in indexed mode and reduced to two colors. Use ImageModeIndexed to convert the image to indexed mode. Make sure that Use black and white (1-bit) palette is checked.

保存图层

Since GIMP-2.10.12, you can save layers when exporting to TIFF. Each layer will be a separate page in the TIFF image.

Crop layers to image bounds

When Save layers is checked, this option, which is enabled by default, will resize all layers to the size of the image. TIFF images can not have negative offsets. This option enables you to import the TIFF again without having to change the position of layers that had a different size as the image in the original.

保存透明像素的颜色值

When this is enabled the color values are saved even if the pixels are completely transparent.

注释

在此文本框中,您可以输入与图像关联的注释。

保存 Exif 数据

When this option is enabled existing EXIF metadata will be saved in the exported TIFF image.

保存 XMP 数据

When this option is enabled existing XMP metadata will be saved in the exported TIFF image.

保存 IPTC 数据

When this option is enabled existing IPTC metadata will be saved in the exported TIFF image.

保存缩略图

When this option is enabled a thumbnail will be saved as the second page in the exported TIFF image. This will also cause certain EXIF tags to be saved even if you have disabled saving EXIF metadata.

保存色彩配置文件

When this option is enabled the color profile will be saved in the exported TIFF image.

保存 GeoTIFF 数据

When this option is enabled GeoTIFF metadata that was present in the original image will be saved in the exported TIFF image.

1.2.6. 将图像导出为 WebP

图 6.7. The WebP Export dialog

The WebP Export dialog

Lossless

When checked, the image will be saved in a way that keeps the original quality. This disables the Image quality and Alpha quality settings. When unchecked, the image will be saved based on the quality settings below, which may cause some loss of quality, but at a better compression ratio. This is the default.

Image quality, Alpha quality

These settings determine at what quality the image will be saved. A higher image quality usually means a larger filesize. When filesize is important you can check if a lower quality is still good enough for your purposes.

Source Type

This selects the type of image you are trying to export. Presumably this will help in deciding the best way to compress the image.

Choices are: Default, Picture for digital pictures, like portraits or inside shots, Photo for outdoor photography with natural lighting, Drawing for hand or line drawing, with high-contrast details, Icon for small-sized colorful images, and Text for images containing mostly text.

保存 Exif 数据

When this option is enabled existing EXIF metadata will be saved in the exported image.

保存 IPTC 数据

When this option is enabled existing IPTC metadata will be saved in the exported image.

保存 XMP 数据

When this option is enabled existing XMP metadata will be saved in the exported image.

保存色彩配置文件

When this option is enabled the color profile will be saved in the exported image.

保存缩略图

When this option is enabled a thumbnail will be saved in the exported image.

1.2.7. 将图像导出为MNG

图 6.8. 导出MNG文件对话框

导出MNG文件对话框

MNG 是多图像网络图形(Multiple-Image Network Graphics)的缩写。

主要问题是 Konqueror 是唯一识别 MNG 动画格式的 Web 导航器。请参阅http://en.wikipedia.org/wiki/Multiple-image_Network_Graphics