Skip to content

Commit 054d853

Browse files
committed
add cmyk and flatten operations (WIP)
1 parent 3658754 commit 054d853

1 file changed

Lines changed: 32 additions & 3 deletions

File tree

graphicscache.dtx

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@
237237
\newif\ifgraphicscache@trim
238238
\newif\ifgraphicscache@clip
239239
\newif\ifgraphicscache@fullclip
240+
\newif\ifgraphicscache@flatten\graphicscache@flattenfalse
241+
\newif\ifgraphicscache@cmyk\graphicscache@cmykfalse
240242
\def\graphicscache@graphicsargs{}
241243
\newlength\graphicscache@tmplen
242244
\newcommand{\graphicscache@addarg}[1]{%
@@ -268,15 +270,20 @@
268270
% \end{macrocode}
269271
% \begin{macrocode}
270272
compress/.is choice,
271-
compress/false/.code={\graphicscache@compressfalse},
273+
compress/false/.code={\graphicscache@compressfalse \def\graphicscache@compress@mode{off}},
272274
compress/jpeg/.code={\graphicscache@compresstrue \def\graphicscache@compress@mode{DCTEncode}},
273-
compress/flat/.code={\graphicscache@compresstrue \def\graphicscache@compress@mode{FlatEncode}},
275+
compress/flat/.code={\graphicscache@compresstrue \def\graphicscache@compress@mode{FlateEncode}},
276+
compress/flate/.code={\graphicscache@compresstrue \def\graphicscache@compress@mode{FlateEncode}},
274277
compress=jpeg,
275278
% \end{macrocode}
276279
% \begin{macrocode}
277280
dpi/.store in=\graphicscache@dpi,
278281
dpi=300,
279282
% \end{macrocode}
283+
% \begin{macrocode}
284+
flatten/.is if=graphicscache@flatten,
285+
cmyk/.is if=graphicscache@cmyk,
286+
% \end{macrocode}
280287
% \begin{macrocode}
281288
qfactor/.store in=\graphicscache@qfactor,
282289
qfactor={0.15},
@@ -375,13 +382,28 @@
375382
% This macro calls ghostscript using the name specified in the first argument.
376383
% \begin{macrocode}
377384
\newcommand{\graphicscache@callgswithname}[1]{%
385+
\ifgraphicscache@flatten
386+
\def\graphicscache@flattenarg{-dHaveTransparency=false}%
387+
\else
388+
\def\graphicscache@flattenarg{}%
389+
\fi
390+
\ifgraphicscache@cmyk
391+
\def\graphicscache@cmykarg{%
392+
-sProcessColorModel=DeviceCMYK
393+
-sColorConversionStrategy=CMYK
394+
-sColorConversionStrategyForImages=CMYK
395+
}%
396+
\else
397+
\def\graphicscache@cmykarg{}%
398+
\fi
378399
\ifwindows
379400
\graphicscache@ShellEscape{#1
380401
-sOutputFile=\graphicscache@output\space
381402
-sDEVICE=pdfwrite
382403
-dCompatibilityLevel=1.4
383404
-dPDFSETTINGS=/prepress
384405
-dNOPAUSE -dQUIET -dBATCH
406+
\graphicscache@flattenarg \graphicscache@cmykarg
385407
-c "<<
386408
/AutoFilterColorImages false
387409
/EncodeColorImages true
@@ -403,6 +425,7 @@
403425
-dCompatibilityLevel=1.4
404426
-dPDFSETTINGS=/prepress
405427
-dNOPAUSE -dQUIET -dBATCH
428+
\graphicscache@flattenarg \graphicscache@cmykarg
406429
-c '<<
407430
/AutoFilterColorImages false
408431
/EncodeColorImages true
@@ -724,7 +747,13 @@
724747
\else
725748
\def\graphicscache@clipmode{nclip}%
726749
\fi
727-
\edef\graphicscache@outputhash{\pdf@mdfivesum{\graphicscache@options\graphicscache@graphicsargs\graphicscache@clipmode\graphicscache@hashedname}}%
750+
\ifgraphicscache@flatten
751+
\edef\graphicscache@clipmode{\graphicscache@clipmode{}flat}%
752+
\fi
753+
\ifgraphicscache@cmyk
754+
\edef\graphicscache@clipmode{\graphicscache@clipmode{}cmyk}%
755+
\fi
756+
\edef\graphicscache@outputhash{\pdf@mdfivesum{\graphicscache@options\graphicscache@graphicsargs\graphicscache@clipmode\graphicscache@compress@mode\graphicscache@hashedname}}%
728757
\edef\graphicscache@output{\graphicscache@cachedir/\graphicscache@outputhash.pdf}%
729758
\ifgraphicscache@listing
730759
\PackageInfo{graphicscache}{graphicscache: includegraphics\{#2\} => \graphicscache@output}%

0 commit comments

Comments
 (0)