summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/graphicxpsd
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/graphicxpsd
Initial commit
Diffstat (limited to 'macros/latex/contrib/graphicxpsd')
-rw-r--r--macros/latex/contrib/graphicxpsd/LICENSE7
-rw-r--r--macros/latex/contrib/graphicxpsd/README.md31
-rw-r--r--macros/latex/contrib/graphicxpsd/graphicxpsd.pdfbin0 -> 168655 bytes
-rw-r--r--macros/latex/contrib/graphicxpsd/graphicxpsd.sty98
-rw-r--r--macros/latex/contrib/graphicxpsd/graphicxpsd.tex107
-rw-r--r--macros/latex/contrib/graphicxpsd/test-gin-rule-psd.tex55
-rw-r--r--macros/latex/contrib/graphicxpsd/tigerpsdfmt.psdbin0 -> 851751 bytes
7 files changed, 298 insertions, 0 deletions
diff --git a/macros/latex/contrib/graphicxpsd/LICENSE b/macros/latex/contrib/graphicxpsd/LICENSE
new file mode 100644
index 0000000000..72d2a71e6f
--- /dev/null
+++ b/macros/latex/contrib/graphicxpsd/LICENSE
@@ -0,0 +1,7 @@
+Copyright (c) 2017, 2018 Munehiro Yamamoto
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/macros/latex/contrib/graphicxpsd/README.md b/macros/latex/contrib/graphicxpsd/README.md
new file mode 100644
index 0000000000..26b3e45104
--- /dev/null
+++ b/macros/latex/contrib/graphicxpsd/README.md
@@ -0,0 +1,31 @@
+# graphicxpsd Package
+
+LaTeX: Adobe Photoshop Data format (PSD) support for graphicx package via PSD-to-PDF conversion
+
+This package provides Adobe Photoshop Data format (PSD) support for graphicx package
+with `sips` (Darwin/macOS)/`magick` (ImageMagick) command.
+
+ * Major drivers support: `dvipdfmx`, `xetex`, `pdftex`, `luatex`
+
+
+## Requirements
+
+ * recent [TeX Live](https://www.tug.org/texlive/) environment
+ (TeX Live 2012 or higher release version)
+ * Mac OS X or [ImageMagick](https://www.imagemagick.org/)
+
+
+## Installation
+
+Copy: `graphicxpsd.sty` -> `$TEXMF/tex/latex/graphicxpsd/`
+
+
+## License
+
+This package is licensed under the terms of the MIT License.
+
+
+--------------------
+
+Munehiro Yamamoto
+https://github.com/munepi
diff --git a/macros/latex/contrib/graphicxpsd/graphicxpsd.pdf b/macros/latex/contrib/graphicxpsd/graphicxpsd.pdf
new file mode 100644
index 0000000000..de0ecdc579
--- /dev/null
+++ b/macros/latex/contrib/graphicxpsd/graphicxpsd.pdf
Binary files differ
diff --git a/macros/latex/contrib/graphicxpsd/graphicxpsd.sty b/macros/latex/contrib/graphicxpsd/graphicxpsd.sty
new file mode 100644
index 0000000000..3f170d9c2f
--- /dev/null
+++ b/macros/latex/contrib/graphicxpsd/graphicxpsd.sty
@@ -0,0 +1,98 @@
+% #!rm -f tigerpsdfmt4* && ptex2pdf -l -u -ot '-shell-escape' -od '-v' test-gin-rule-psd
+% #!rm -f tigerpsdfmt4* && xelatex -shell-escape test-gin-rule-psd
+% #!rm -f tigerpsdfmt4* && pdflatex -shell-escape test-gin-rule-psd
+%#!rm -f tigerpsdfmt4* && lualatex -shell-escape test-gin-rule-psd
+%%
+%% This is file 'graphicxpsd.sty'.
+%%
+%% Copyright (c) 2017, 2018 Munehiro Yamamoto
+%%
+%% * e-mail: munepixyz@gmail.com, munepi@greencherry.jp
+%% * GitHub: https://github.com/munepi
+%% * Twitter: @munepixyz
+%%
+%% This package is licensed under the terms of the MIT License.
+%%
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{graphicxpsd}
+ [2018/01/30 v1.1 Adobe Photoshop Data format (PSD) support for graphicx package
+ with sips (Darwin/macOS)/magick (ImageMagick) command]
+
+%% declare package errors
+\def\gfxpsd@error{\PackageError{graphicxpsd}}
+\def\gfxpsd@warning{\PackageWarning{graphicxpsd}}
+\def\gfxpsd@warningnoline{\PackageWarningNoLine{graphicxpsd}}
+\def\gfxpsd@info{\PackageInfo{graphicxpsd}}
+
+%% support major graphicx drivers
+\newif\if@gfxpsd@dvipdfmx \@gfxpsd@dvipdfmxfalse
+\newif\if@gfxpsd@pdftex \@gfxpsd@pdftexfalse
+\DeclareOption{dvipdfmx}{\@gfxpsd@dvipdfmxtrue\@gfxpsd@pdftexfalse}
+\DeclareOption{xetex}{\@gfxpsd@dvipdfmxtrue\@gfxpsd@pdftexfalse}
+\DeclareOption{luatex}{\@gfxpsd@dvipdfmxfalse\@gfxpsd@pdftextrue}
+\DeclareOption{pdftex}{\@gfxpsd@dvipdfmxfalse\@gfxpsd@pdftextrue}
+
+%% support two psd-to-pdf commands:
+%% sips (Darwin/macOS), magick/convert (ImageMagick)
+\newif\if@gfxpsd@imagemagick \@gfxpsd@imagemagickfalse
+\def\@gfxpsd@psdtopdf{sips}%% as default
+\DeclareOption{sips}{%
+ \@gfxpsd@imagemagickfalse\gdef\@gfxpsd@psdtopdf{sips}}
+\DeclareOption{imagemagick}{%
+ \@gfxpsd@imagemagicktrue\gdef\@gfxpsd@psdtopdf{magick}}
+\DeclareOption{magick}{%
+ \@gfxpsd@imagemagicktrue\gdef\@gfxpsd@psdtopdf{magick}}
+\DeclareOption{convert}{%
+ \@gfxpsd@imagemagicktrue\gdef\@gfxpsd@psdtopdf{convert}}
+
+\ProcessOptions\relax
+
+%% support the extension .psd (psdtopdf)
+\if@gfxpsd@dvipdfmx
+ \@namedef{Gin@rule@.PSD}#1{{psdtopdf}{.xbb}{#1}}
+ \@namedef{Gin@rule@.psd}#1{{psdtopdf}{.xbb}{#1}}
+\else\if@gfxpsd@pdftex
+ \@namedef{Gin@rule@.PSD}#1{{psdtopdf}{.pdf}{#1}}
+ \@namedef{Gin@rule@.psd}#1{{psdtopdf}{.pdf}{#1}}
+\else
+ \gfxpsd@error{Please choice specific dviware driver from the following list
+ and set the one as a documentclass option.^^J
+ available dviware drivers: dvipdfmx, xetex, luatex, pdftex}%
+\fi\fi
+
+%% then, include .psd file as converted PDF
+\@ifundefined{Ginclude@pdf}{\gfxpsd@error{%
+ Please load 'graphicxpsd' package after loading 'graphicx' package.}}\relax
+\let\Ginclude@psdtopdf\Ginclude@pdf
+
+%% compatibility for TL16 or lower version
+\@ifundefined{GPT@space}{%
+ \def\GPT@space{ }%
+}{}
+
+%% check shell escape trigger
+\IfFileExists{shellesc.sty}{%%is bundled in TL15 or higher release version
+\RequirePackage{shellesc}}{%%otherwise, such TL has no luatex.
+ \protected\def\ShellEscape{\immediate\write18 }%%compatibility for TL14 or lower version
+}
+
+%% read .psd file
+\let\clone@Gread@pdf\Gread@pdf
+\def\Gread@psdtopdf#1{%
+ \typeout{converting: \Gin@base\Gin@ext\GPT@space -> \Gin@base4gfxpsd.pdf}%
+ \if@gfxpsd@imagemagick
+ \ShellEscape{\@gfxpsd@psdtopdf\GPT@space\Gin@base\Gin@ext\GPT@space\Gin@base4gfxpsd.pdf}%
+ \else
+ \ShellEscape{sips -s format pdf \Gin@base\Gin@ext\GPT@space --out \Gin@base4gfxpsd.pdf}%
+ \fi
+ %% renamed inside: foo.psd -> foo4gfxpsd.pdf
+ \let\clone@Gin@base\Gin@base
+ \def\Gin@base{\clone@Gin@base4gfxpsd}%
+ \def\Gin@ext{.pdf}%
+% \typeout{!!! #1}%%=> tigerpsdfmt4gfxpsd.xbb
+% \typeout{!!! \Gin@base\Gin@ext}%%=> tigerpsdfmt4gfxpsd.pdf
+ \clone@Gread@pdf{#1}}
+
+\endinput
+%%
+%% End of file `graphicxpsd.sty'.
diff --git a/macros/latex/contrib/graphicxpsd/graphicxpsd.tex b/macros/latex/contrib/graphicxpsd/graphicxpsd.tex
new file mode 100644
index 0000000000..2c0631b7ed
--- /dev/null
+++ b/macros/latex/contrib/graphicxpsd/graphicxpsd.tex
@@ -0,0 +1,107 @@
+%#!rm -f tigerpsdfmt4* && lualatex -shell-escape graphicxpsd
+\documentclass[luatex]{article}
+\usepackage{shortvrb}\MakeShortVerb{\|}
+\usepackage{hyperref}
+\usepackage{graphicx}
+\usepackage{graphicxpsd}
+\title{\textsf{graphicxpsd} Package}
+\author{Munehiro Yamamoto}
+\date{2018/01/30 v1.1}
+\begin{document}
+\maketitle
+\begin{abstract}
+This package provides Adobe Photoshop Data format (PSD) support
+for \textsf{graphicx} package
+with \texttt{sips} (Darwin/macOS)/\texttt{magick} (ImageMagick) command.
+\end{abstract}
+
+\section{Motivation}
+\textsf{graphicx} package supports already many graphics image formats as bellow.
+\begin{itemize}
+\item non-vector formats: jpg, png, bmp, and so on
+\item PostScript-style formats: eps, ps
+\item PDF-style formats: pdf, ai
+\end{itemize}
+However, it currently does not support Adobe Photoshop Data format (PSD).
+
+Against that, we developed the \textsf{graphicxpsd} package
+to support PSD format via PSD-to-PDF conversion
+with two image converters.
+\begin{itemize}
+\item \texttt{sips}:
+pre-installed command in Darwin/macOS
+
+\item \texttt{magick}:
+bundled command in \href{https://www.imagemagick.org/}{ImageMagick}
+\end{itemize}
+
+\section{Loading \textsf{graphicxpsd} Package}
+
+Load \textsf{graphicxpsd} package after loading \textsf{graphicx} package.
+
+\begin{quote}
+\begin{verbatim}
+\usepackage{graphicx}
+\usepackage[<options>]{graphicxpsd}
+\end{verbatim}
+\end{quote}
+
+The list of available options is the following.
+\begin{itemize}
+\item |dvipdfmx|, |xetex|, |pdftex|, |luatex|:
+supported driver options;
+You can also give specific driver option from global option.
+
+\item |sips| (default), |magick| (same as |imagemagick|), |convert|\footnotemark:
+supported image converters;
+\begin{itemize}
+\item
+Darwin/macOS users do not have to do anything
+unless you choose ImageMagick as PSD-to-PDF converter.
+\item
+If you use ImageMagick~7, you may choose |magick|.
+\item
+If you should use ImageMagick~6 or lower version, you just choose |convert|.
+\end{itemize}
+\end{itemize}
+\footnotetext{When ImageMagick project had released ImageMagick~7,
+they changed \texttt{convert} to \texttt{magick}
+because that might be the usual problem with the conflict of names
+between the ImageMagick's \texttt{convert.exe} and
+the Windows ``\texttt{convert.exe}'' program,
+which complains about invalid parameters, and
+changing the Imagemagick program's name to imconvert and
+using that instead avoided the conflict.}
+
+\section{Example}
+
+Typeset the following {\LaTeX} document with Lua{\TeX} enabling the shell escape,
+that is, run |lualatex -shell-escape|.
+\begin{quote}
+\small
+\begin{verbatim}
+%#!lualatex -shell-escape
+\documentclass[luatex]{article}%%set luatex driver as global option
+\usepackage{graphicx}
+\usepackage{graphicxpsd}
+\begin{document}
+\includegraphics{tigerpsdfmt.psd}
+\end{document}
+\end{verbatim}
+\end{quote}
+Then, the result is as below.
+\begin{center}
+\includegraphics{tigerpsdfmt.psd}
+\end{center}
+Incidentally, the above \texttt{tigerpsdfmt.psd} file is converted from
+the \texttt{tiger.eps} file (a.k.a.~``cubic spline tiger''),
+which comes with Ghostscript.
+\begin{quote}
+\small
+\begin{verbatim}
+$ file tigerpsdfmt.psd
+tigerpsdfmt.psd: Adobe Photoshop Image, 550 x 568, RGBA, 4x 8-bit channels
+\end{verbatim}
+\end{quote}
+
+\end{document}
diff --git a/macros/latex/contrib/graphicxpsd/test-gin-rule-psd.tex b/macros/latex/contrib/graphicxpsd/test-gin-rule-psd.tex
new file mode 100644
index 0000000000..6c45eb617f
--- /dev/null
+++ b/macros/latex/contrib/graphicxpsd/test-gin-rule-psd.tex
@@ -0,0 +1,55 @@
+% #!rm -f tigerpsdfmt4* && ptex2pdf -l -u -ot '-shell-escape' -od '-v' test-gin-rule-psd
+% #!rm -f tigerpsdfmt4* && xelatex -shell-escape test-gin-rule-psd
+% #!rm -f tigerpsdfmt4* && pdflatex -shell-escape test-gin-rule-psd
+%#!rm -f tigerpsdfmt4* && lualatex -shell-escape test-gin-rule-psd
+\documentclass[luatex]{article}%%set driver as global option
+\usepackage{graphicx}
+\usepackage[%
+ magick,%imagemagick,%%same as the one; %%default: sips
+ % convert,%% old ImageMagick
+]{graphicxpsd}
+\listfiles
+\begin{document}
+\makeatletter
+PSD-to-PDF: \@gfxpsd@psdtopdf
+\makeatother
+
+%% $ file tigerpsdfmt.psd
+%% tigerpsdfmt.psd: Adobe Photoshop Image, 550 x 568, RGBA, 4x 8-bit channels
+\includegraphics{tigerpsdfmt.psd}
+\end{document}
+
+$ pdfinfo tigerpsdfmt4gfxpsd.pdf
+Title: tigerpsdfmt4gfxpsd
+Producer: /opt/homebrew/Cellar/imagemagick/7.0.7-15/share/doc/ImageMagick-7//index.html
+CreationDate: Sat Jan 27 00:10:51 2018 JST
+ModDate: Sat Jan 27 00:10:51 2018 JST
+Tagged: no
+UserProperties: no
+Suspects: no
+Form: none
+JavaScript: no
+Pages: 2
+Encrypted: no
+Page size: 99 x 102.24 pts
+Page rot: 0
+File size: 1052740 bytes
+Optimized: no
+PDF version: 1.4
+
+$ pdfinfo tigerpsdfmt4gfxpsd.pdf
+Producer: Mac OS X 10.13.4 Quartz PDFContext
+CreationDate: Fri Jan 26 15:12:13 2018 JST
+ModDate: Fri Jan 26 15:12:13 2018 JST
+Tagged: no
+UserProperties: no
+Suspects: no
+Form: none
+JavaScript: no
+Pages: 1
+Encrypted: no
+Page size: 99 x 102.24 pts
+Page rot: 0
+File size: 112882 bytes
+Optimized: no
+PDF version: 1.3 \ No newline at end of file
diff --git a/macros/latex/contrib/graphicxpsd/tigerpsdfmt.psd b/macros/latex/contrib/graphicxpsd/tigerpsdfmt.psd
new file mode 100644
index 0000000000..6fc50edeb1
--- /dev/null
+++ b/macros/latex/contrib/graphicxpsd/tigerpsdfmt.psd
Binary files differ