invert colors in \externalfigure
Dear list, I have the following sample: \setuppapersize[A6] \setuplayout[width=middle] \starttext \startmakeup[standard][align=center] \dontleavehmode\externalfigure[cow][width=\textwidth] \stopmakeup \stoptext How can I invert the colors in the external figure without having to edit the image file? Many thanks for your help, Pablo -- http://www.ousia.tk
Pablo Rodriguez mailto:oinos@gmx.es 20. Januar 2016 um 13:10 Dear list,
I have the following sample:
\setuppapersize[A6] \setuplayout[width=middle] \starttext \startmakeup[standard][align=center] \dontleavehmode\externalfigure[cow][width=\textwidth] \stopmakeup \stoptext
How can I invert the colors in the external figure without having to edit the image file?
Many thanks for your help, You have to use the Adobe Reader to view the PDF.
\setupexternalfigure[location=default] \starttext \externalfigure[cow][width=\textwidth] \startnegative \externalfigure[cow][width=\textwidth] \stopnegative \startnegative \externalfigure[cow][background=color,backgroundcolor=white,width=\textwidth] \stopnegative \stoptext Wolfgang
On 01/20/2016 01:19 PM, Wolfgang Schuster wrote:
Pablo Rodriguez 20. Januar 2016 um 13:10 [...] How can I invert the colors in the external figure without having to edit the image file?
Many thanks for your help, You have to use the Adobe Reader to view the PDF.
Many thanks for your solution, Wolfgang. I’m afraid that I’m on Linux and I don’t have Adobe Reader installed. But it is fine for me, since I’m going to print the file with Adobe Reader DC. It seems that other viewers don’t implement the /TR entry from /ExtGState dictionary (according to the PDF spec). I’m going to report the issue for Ghostscript, mupdf and poppler, so that they have the feature implemented. Many thanks for your help, Pablo
\setupexternalfigure[location=default]
\starttext
\externalfigure[cow][width=\textwidth]
\startnegative \externalfigure[cow][width=\textwidth] \stopnegative
\startnegative \externalfigure[cow][background=color,backgroundcolor=white,width=\textwidth] \stopnegative
\stoptext
Wolfgang
On Wed, 20 Jan 2016 17:56:53 +0100
Pablo Rodriguez
On 01/20/2016 01:19 PM, Wolfgang Schuster wrote:
Pablo Rodriguez 20. Januar 2016 um 13:10 [...] How can I invert the colors in the external figure without having to edit the image file?
Many thanks for your help, You have to use the Adobe Reader to view the PDF.
I’m afraid that I’m on Linux and I don’t have Adobe Reader installed.
Not just on Linux... (Adobe reader is a notorious security hole). With MetaFun, you can invert the colors using: \startMPcode draw whatever... ; currentpicture := inverted currentpicture ; \stopMPcode Unfortunately, this does *not* work with externalfigure, i.e. \startMPcode draw externalfigure("cow") ; currentpicture := inverted currentpicture ; \stopMPcode or \startMPcode draw rawtextext("\externalfigure [cow]") ; currentpicture := inverted currentpicture ; \stopMPcode as inverted (a macro) operates on all the elements of the picture. I find it easiest to use ImageMagick or gimp to invert the colors and save this in a second image file. Alan
On 01/20/2016 07:35 PM, Alan BRASLAU wrote:
On Wed, 20 Jan 2016 17:56:53 +0100 Pablo Rodriguez wrote:
On 01/20/2016 01:19 PM, Wolfgang Schuster wrote:
Pablo Rodriguez 20. Januar 2016 um 13:10 [...] How can I invert the colors in the external figure without having to edit the image file?
Many thanks for your help, You have to use the Adobe Reader to view the PDF.
I’m afraid that I’m on Linux and I don’t have Adobe Reader installed.
Not just on Linux... (Adobe reader is a notorious security hole).
Many thanks for your reply, Alan. \startnegative is the way of doing it, as Wolfgang suggested. Don’t worry, I won’t install Adobe Reader. Ghostscript also implements what actually is the /TR (transformation) entry for /ExtGState (graphics state) dictionary. (I was wrong in my previous message.) Only poppler and mupdf should implement it. Many thanks for your help, Pablo -- http://www.ousia.tk
How can I invert the colors in the external figure without having to edit the image file?
Based on Peter Münster's grph-downsample.lua here some lines that should get you started. Note that you'll need graphicsmagick (or imagemagick for that matter. In the latter case change the call from `gm convert` to `convert`). This will do the conversion on the fly. \startluacode local format = string.format local function invert(oldname, newname) local s = format("gm convert -negate %s %s", oldname, newname) os.execute(s) end local formats = {"png", "jpg", "gif"} for _, s in ipairs(formats) do figures.converters[s] = figures.converters[s] or {} figures.converters[s]["invert." .. s] = invert end \stopluacode \setupexternalfigures [conversion=invert.jpg] \setupexternalfigures [location=default] \starttext \externalfigure[hacker] \stoptext Marco
On 01/20/2016 02:09 PM, Marco Patzer wrote:
How can I invert the colors in the external figure without having to edit the image file?
Based on Peter Münster's grph-downsample.lua here some lines that should get you started. Note that you'll need graphicsmagick (or imagemagick for that matter. In the latter case change the call from `gm convert` to `convert`). This will do the conversion on the fly.
Many thanks for your reply, Marco. I’m afraid it doesn’t work with PDF files. But it is fine for me, since the solution provided by Wolfgang works fine. Many thanks for your help, Pablo -- http://www.ousia.tk
participants (4)
-
Alan BRASLAU
-
Marco Patzer
-
Pablo Rodriguez
-
Wolfgang Schuster