> For the complete documentation index, see [llms.txt](https://overleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://overleaf-pro.ayaka.space/latex/zh-cn/zhi-shi-ku/113-optimising-very-large-image-files.md).

# 优化非常大的图像文件

过大的图像文件，或使用不合适文件格式的图像文件，可能会显著延长编译过程，并有可能导致编译超时。本帮助文章概述了一些处理大图像文件以及选择合适图像文件格式的建议。

对于大型图像文件（每个大小超过 1MB），我们建议将光栅图像（包括光栅 PDF 图像）重新缩放，例如缩放到宽或高 1200px，以便减小文件大小。你可以使用图像处理程序来完成；或者如果你使用 ImageMagick，你可以使用 [`convert` 命令](http://www.imagemagick.org/Usage/resize). 在 MacOS 上， [`sips -Z` 命令](http://lifehacker.com/5962420/batch-resize-images-quickly-in-the-os-x-terminal) 非常有用。

保存为 `.png` 的照片也会导致非常大的文件大小： `.jpg` 通常是一种更节省空间的格式，适用于 *照片*. *线条图、曲线图和示意图* 通常更适合保存为 `.png` 或 `.pdf`。 `.pdf` 图像文件如果文件大小相近，编译速度也可能比 `.png` 文件更快，因为编译过程就不需要调用 `libpng`.

对于 `.eps` 图像，我们建议将其转换为 `.pdf`，因为 PDF 格式通常能在保持线条图矢量特性的同时产生更小的文件大小。这个 [`epstopdf` 命令](https://www.ctan.org/pkg/epstopdf) 很方便；你还需要安装 GhostScript。

如果你必须在项目中使用 `.eps` 图像，有时 `.eps` 文件会因为导出它们的应用程序存在故障/配置错误而异常庞大。你可以尝试修改导出设置；或者仅用 GhostScript 重新处理该文件并比较文件大小：

```
gs -o outputfile.eps -sDEVICE=epswrite originalfile.eps
```

如果你希望在处理文档时减少一些编译/渲染时间，可以通过在文档中写入来开启“draft”模式，使编译更快： `\documentclass[draft]{…}` 在你的文档类声明中。通过不将图像渲染到 PDF 中（以及其他一些操作），“draft”选项通常可以帮助缩短编译时间，这在处理大型文档时很有用。

你还可以为你正在处理的项目中的某个特定部分开启/关闭图形：

```latex
\setkeys{Gin}{draft=false}
...这里的任何 \includegraphics 都会以完整效果渲染，因此
你可以检查文档这一部分中的图像..
\setkeys{Gin}{draft}
...这里的任何 \includegraphics 都只会显示为一个空白边框。
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://overleaf-pro.ayaka.space/latex/zh-cn/zhi-shi-ku/113-optimising-very-large-image-files.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
