当我从 Tikz 生成文件时,如何减小 eps 文件的文件大小?

当我从 Tikz 生成文件时,如何减小 eps 文件的文件大小?

我读过类似这样的帖子如何减小 .eps 文件的大小?Eps 文件太大[关闭]Sun life:Linux:如何减小 eps 文件大小?但发现几乎没有什么可以帮助我解决问题。

Sun life:Linux:如何减小 eps 文件大小?这可以用于我的论文中的一些图表,但不能用于全部,正如评论中提到的那样。

所以我首先上传我的mange.tex代码,因为我用它来组合所有子图。

这是所需的vector.eps:

矢量0.eps

矢量1.eps

矢量2.eps

    % Rusting Iron
% Author: Jason Waskiewicz
% A "jazzy" picture of the stages of rust (presented for a high school level).
% Iron is red, oxygen is blue and electrons are black. At the left you see
% iron atoms with two oxygen molecules, then the electrons go to the oxygen molecules
% leaving oxygen ions and iron ions which then disolve.
\documentclass[tikz]{standalone}
\usetikzlibrary{positioning}
\usepackage{lmodern}
\newcommand{\tikzmark}[2]{\tikz[remember picture, baseline] \node[inner sep=0pt, outer sep=0pt, anchor=base] (#1) {#2};}

\newcommand{\ZuiDa}{\fontsize{72pt}{0.5pt}}

\begin{document}

\begin{tikzpicture}[
        >=stealth,
        %show background rectangle, 
        iron/.style={ball color=red},
        electron/.style={ball color=green},
        oxygen/.style={ball color=blue},
        B/.style={ball color=yellow},
        A/.style={ball color=violet},
        Dark/.style={ball color=black},
    ]

\def\r{1.0}
\def\xshiftdist{18}
\def\xdoubleshiftdist{36}
\def\xtripleshiftdist{50}

\node (A) at(0,0) {
{\includegraphics[width=5.5\textwidth]{vector0.eps}}
};

\draw (-36,0.0) node { \ZuiDa \textbf{(\emph{a})}};

%上墙
\draw [line width  = 15 mm] (-34,5)  -- (34,5) ;

%Period 1


\foreach \x in {-33.00000, -31.00000, -29.00000, -27.00000}
            \draw [iron] (\x,-5.3,0) circle (\r);
            
\foreach \x in {-25.00000}
           \draw [electron] (\x,-5.3,0) circle (\r);

   \foreach \x in {-23.00000, -21.00000,-19.00000, -17.00000}
            \draw [oxygen] (\x,-5.3,0) circle (\r);
            
%Period 2 %,xshift =  \xshiftdist cm

\foreach \x in {-33.00000, -31.00000, -29.00000, -27.00000}
            \draw [iron,xshift =  \xshiftdist cm] (\x,-5.3,0) circle (\r);
            
\foreach \x in {-25.00000}
           \draw [electron,xshift =  \xshiftdist cm] (\x,-5.3,0) circle (\r);

   \foreach \x in {-23.00000, -21.00000,-19.00000, -17.00000}
            \draw [oxygen,xshift =  \xshiftdist cm] (\x,-5.3,0) circle (\r);


%Period 3 ,xshift =  \xdoubleshiftdist cm


\foreach \x in {-33.00000, -31.00000, -29.00000, -27.00000}
            \draw [iron,xshift =  \xdoubleshiftdist cm] (\x,-5.3,0) circle (\r);
            
\foreach \x in {-25.00000}
           \draw [electron,xshift =  \xdoubleshiftdist cm] (\x,-5.3,0) circle (\r);

   \foreach \x in {-23.00000, -21.00000,-19.00000, -17.00000}
            \draw [oxygen,xshift =  \xdoubleshiftdist cm] (\x,-5.3,0) circle (\r);
            
%Period 4 %,xshift =  \xtripleshiftdist cm

\foreach \x in {-33.00000, -31.00000, -29.00000, -27.00000}
            \draw [iron,xshift =  \xtripleshiftdist cm] (\x,-5.3,0) circle (\r);
            
\foreach \x in {-25.00000}
           \draw [electron,xshift =  \xtripleshiftdist cm] (\x,-5.3,0) circle (\r);

   \foreach \x in {-23.00000, -21.00000,-19.00000, -17.00000}
            \draw [oxygen,xshift =  \xtripleshiftdist cm] (\x,-5.3,0) circle (\r);

%
% (b)
%
\def\rptwoUP{-10.5}
\def\rptwoDOWN{-19.5}


\node[right=of A] (B) at (-35,-15){
{\includegraphics[width=5.5\textwidth]{vector1.eps}}
};
\draw (-36,-15.0) node { \ZuiDa \textbf{(\emph{b})}};

%Period 1
%%up
\foreach \x in {-33.00000, -31.00000, -29.00000, -27.00000}
            \draw [iron] (\x,\rptwoUP,0) circle (\r);
            
\foreach \x in {-25.00000}
           \draw [Dark] (\x,\rptwoUP,0) circle (\r);

   \foreach \x in {-23.00000, -21.00000,-19.00000, -17.00000}
            \draw [oxygen] (\x,\rptwoUP,0) circle (\r);

%%down
\foreach \x in {-33.00000, -31.00000, -29.00000, -27.00000}
            \draw [iron] (\x,\rptwoDOWN,0) circle (\r);
            
\foreach \x in {-25.00000}
           \draw [electron] (\x,\rptwoDOWN,0) circle (\r);

   \foreach \x in {-23.00000, -21.00000,-19.00000, -17.00000}
            \draw [oxygen] (\x,\rptwoDOWN,0) circle (\r);
            
%Period 2 %,xshift =  \xshiftdist cm
%%up
\foreach \x in {-33.00000, -31.00000, -29.00000, -27.00000}
            \draw [iron,xshift =  \xshiftdist cm] (\x,\rptwoUP,0) circle (\r);
            
\foreach \x in {-25.00000}
           \draw [Dark,xshift =  \xshiftdist cm] (\x,\rptwoUP,0) circle (\r);

   \foreach \x in {-23.00000, -21.00000,-19.00000, -17.00000}
            \draw [oxygen,xshift =  \xshiftdist cm] (\x,\rptwoUP,0) circle (\r);

%%down
\foreach \x in {-33.00000, -31.00000, -29.00000, -27.00000}
            \draw [iron,xshift =  \xshiftdist cm] (\x,\rptwoDOWN,0) circle (\r);
            
\foreach \x in {-25.00000}
           \draw [electron,xshift =  \xshiftdist cm] (\x,\rptwoDOWN,0) circle (\r);

   \foreach \x in {-23.00000, -21.00000,-19.00000, -17.00000}
            \draw [oxygen,xshift =  \xshiftdist cm] (\x,\rptwoDOWN,0) circle (\r);


%Period 3 ,xshift =  \xdoubleshiftdist cm
%%up
\foreach \x in {-33.00000, -31.00000, -29.00000, -27.00000}
            \draw [iron,xshift =  \xdoubleshiftdist cm] (\x,\rptwoUP,0) circle (\r);
            
\foreach \x in {-25.00000}
           \draw [Dark,xshift =  \xdoubleshiftdist cm] (\x,\rptwoUP,0) circle (\r);

   \foreach \x in {-23.00000, -21.00000,-19.00000, -17.00000}
            \draw [oxygen,xshift =  \xdoubleshiftdist cm] (\x,\rptwoUP,0) circle (\r);

%%down
\foreach \x in {-33.00000, -31.00000, -29.00000, -27.00000}
            \draw [iron,xshift =  \xdoubleshiftdist cm] (\x,\rptwoDOWN,0) circle (\r);
            
\foreach \x in {-25.00000}
           \draw [electron,xshift =  \xdoubleshiftdist cm] (\x,\rptwoDOWN,0) circle (\r);

   \foreach \x in {-23.00000, -21.00000,-19.00000, -17.00000}
            \draw [oxygen,xshift =  \xdoubleshiftdist cm] (\x,\rptwoDOWN,0) circle (\r);
            
%Period 4 %,xshift =  \xtripleshiftdist cm




%
% c
%

\def\rptwoUP{-24.2}
\def\rptwoDOWN{-34}

\node[right=of A] (B) at (-35,-29){
{\includegraphics[width=5.5\textwidth]{vector2.eps}}
};
\draw (-36,-28.0) node { \ZuiDa \textbf{(\emph{c})}};

%%up
\foreach \x in {-33.00000, -31.00000, -29.00000, -27.00000}
            \draw [oxygen] (\x,\rptwoUP,0) circle (\r);
            
\foreach \x in {-25.00000}
           \draw [Dark] (\x,\rptwoUP,0) circle (\r);

   \foreach \x in {-23.00000, -21.00000,-19.00000, -17.00000}
            \draw [iron] (\x,\rptwoUP,0) circle (\r);

%%down
\foreach \x in {-33.00000, -31.00000, -29.00000, -27.00000}
            \draw [iron] (\x,\rptwoDOWN,0) circle (\r);
            
\foreach \x in {-25.00000}
           \draw [electron] (\x,\rptwoDOWN,0) circle (\r);

   \foreach \x in {-23.00000, -21.00000,-19.00000, -17.00000}
            \draw [oxygen] (\x,\rptwoDOWN,0) circle (\r);
            
%Period 2 %,xshift =  \xshiftdist cm
%%up
\foreach \x in {-33.00000, -31.00000, -29.00000, -27.00000}
            \draw [oxygen,xshift =  \xshiftdist cm] (\x,\rptwoUP,0) circle (\r);
            
\foreach \x in {-25.00000}
           \draw [Dark,xshift =  \xshiftdist cm] (\x,\rptwoUP,0) circle (\r);

   \foreach \x in {-23.00000, -21.00000,-19.00000, -17.00000}
            \draw [iron,xshift =  \xshiftdist cm] (\x,\rptwoUP,0) circle (\r);

%%down
\foreach \x in {-33.00000, -31.00000, -29.00000, -27.00000}
            \draw [iron,xshift =  \xshiftdist cm] (\x,\rptwoDOWN,0) circle (\r);
            
\foreach \x in {-25.00000}
           \draw [electron,xshift =  \xshiftdist cm] (\x,\rptwoDOWN,0) circle (\r);

   \foreach \x in {-23.00000, -21.00000,-19.00000, -17.00000}
            \draw [oxygen,xshift =  \xshiftdist cm] (\x,\rptwoDOWN,0) circle (\r);
            
%Period 3 ,xshift =  \xdoubleshiftdist cm            
%%up
\foreach \x in {-33.00000, -31.00000, -29.00000, -27.00000}
            \draw [oxygen,xshift =  \xdoubleshiftdist cm ] (\x,\rptwoUP,0) circle (\r);
            
\foreach \x in {-25.00000}
           \draw [Dark,xshift =  \xdoubleshiftdist cm ] (\x,\rptwoUP,0) circle (\r);

   \foreach \x in {-23.00000, -21.00000,-19.00000, -17.00000}
            \draw [iron,xshift =  \xdoubleshiftdist cm ] (\x,\rptwoUP,0) circle (\r);

%%down
\foreach \x in {-33.00000, -31.00000, -29.00000, -27.00000}
            \draw [iron,xshift =  \xdoubleshiftdist cm ] (\x,\rptwoDOWN,0) circle (\r);
            
\foreach \x in {-25.00000}
           \draw [electron,xshift =  \xdoubleshiftdist cm ] (\x,\rptwoDOWN,0) circle (\r);

   \foreach \x in {-23.00000, -21.00000,-19.00000, -17.00000}
            \draw [oxygen,xshift =  \xdoubleshiftdist cm ] (\x,\rptwoDOWN,0) circle (\r);
%node[right=of B] (C) at (-2.641,-2.15){
%{\includegraphics[width=.5\textwidth]{system5.pdf}}
%};
\end{tikzpicture}
\end{document}

这将创建一个 PDF 图形,然后我使用

pdfcrop  --margins '0 0 -908 0' mange.pdf output.pdf 

得到最终结果是这样的:

在此处输入图片描述

我在这里提供:输出.pdf 523.kB

但我需要将此 pdf 转换为 eps,因此我使用以下命令:

 pdftops -eps output.pdf 

生成的eps文件如下:

 pdftops -eps output.pdf 

我在这里提供:输出.eps 2.3MB

但现在我需要根据出版物的要求进一步将 eps 格式的大小缩小到 500 ~ 800 kB。

所以我怎样才能实现这一点呢?

基本上我有两种想法:

  1. 直接缩小 eps 文件,就像这篇文章一样主题:调整 Eps/ps 文件大小但我对最后提到的方法感到困惑,例如

使用它打开 EPS 文件并在 EPS 标题后添加以下行(其中 sx 和 sy 是将图像重新缩放到所需大小所需的因子值)。

按照这个想法,我使用 GIMP 来缩放 eps 文件,但我觉得这会损害图形的质量。真可惜!

  1. 我直接在 Tikz 中将图形转换为 eps,因此我查看了类似的帖子从 TikZ 导出 eps 图形使用 pdfLaTeX 将 TikZ 转换为 EPS但这似乎使问题更加复杂。这就是我提供 Tikz 代码的原因。

有什么想法吗?我该怎么办?

谢谢你!

==============================================

谢谢成本加运费的建议我试过了但是效果似乎很奇怪如下图所示:

在此处输入图片描述

为什么颜色看上去这么淡?

相关内容