Re: [NTG-context] Change color of EPS file.

2012-09-16 Thread Henning Hraban Ramm
2012/9/15 Troy Henderson thend...@gmail.com:
 Utilities are available in abundance which can transform raster graphics
 from color to grayscale, but until I created this yesterday, I have never
 seen a utility that keeps the graphic in vector format (i.e., never
 rasterizes it throughout the conversion) and converts it from color to
 grayscale.  Until I read this thread, I guess I thought I was the only one
 that desired such a tool.  I'm glad to see that at least I'm not alone.

Oh, there are, but I know only commercial (e.g. OneVision Asura) or
in-house solutions (like what I managed at a newspaper several years
ago).
The simple (or simplistic) rgbcolor patch doesn't work with
complicated EPS, of course. But then you'd need to know the structure
of your EPS. It's hard to get that right for arbitrary EPS. And there
aren't that many able PostScript programmers left.
E.g. at that newspaper we were able to switch spot colors just before
plate exposition; the trick was to use a generic spot color name
throughout the workflow and to change its definition in the completed
page EPS. (At that time our printing press was too small to print
all pages in full color.)

Since PostScript is a full programming language, most PS generators
use shortcuts (macros/functions) that wrap the originally simple
commands, so you often can't track down where the structure hides that
you'd like to change. Best solution is often to do a full expansion
with a PS interpreter and write a new, better readable, but mostly
much bigger code. pstoedit is your friend for that – e.g. Hans did
some nice tricks with EPS pictures converted to MetaPost.

I once experimented a bit with changing colors of embedded bitmap
images – it's rather easy to do, but never looks right without a deep
understanding of color management and its strange implementation in
PostScript...

Greetlings, Hraban
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

Re: [NTG-context] Change color of EPS file.

2012-09-15 Thread Rogers, Michael K

On Sep 15, 2012, at 1:36 AM, luigi scarso 
luigi.sca...@gmail.commailto:luigi.sca...@gmail.com
 wrote:
On Sat, Sep 15, 2012 at 1:23 AM, Troy Henderson 
thend...@gmail.commailto:thend...@gmail.com wrote:

and which uses Cairo and Poppler for its conversion.  Now in order for my 
simplistic filter to function,
Why 'simplistic' and not 'simple'  ?
I always thought that its meaning is negative (something like  'simplistic' is 
a bad imitation of 'simple' )

That's often true.  Here I think the intention is to imply that the filter is 
simple and naive, perhaps not robust, might not work for everybody, etc.  In 
that sense, the meaning does have a negative connotation.



This e-mail message (including any attachments) is for the sole use of
the intended recipient(s) and may contain confidential and privileged
information. If the reader of this message is not the intended
recipient, you are hereby notified that any dissemination, distribution
or copying of this message (including any attachments) is strictly
prohibited.

If you have received this message in error, please contact
the sender by reply e-mail message and destroy all copies of the
original message (including attachments).
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

Re: [NTG-context] Change color of EPS file.

2012-09-15 Thread Troy Henderson
Whether the filter is simple or simplistic, it is odd that such a
filter has not been abundantly available before.  I often wondered years
ago when I first started to understand the difference between raster and
vector graphics why something so simple (or simplistic) could not be easily
done.  It was also strange to me that I couldn't easily create a TeX
document with one set of graphics and have TeX generate two types of
output, namely color and a grayscale, depending on the value of some
parameters.

Utilities are available in abundance which can transform raster graphics
from color to grayscale, but until I created this yesterday, I have never
seen a utility that keeps the graphic in vector format (i.e., never
rasterizes it throughout the conversion) and converts it from color to
grayscale.  Until I read this thread, I guess I thought I was the only one
that desired such a tool.  I'm glad to see that at least I'm not alone.

Troy
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

Re: [NTG-context] Change color of EPS file.

2012-09-14 Thread pol stra
Aditya Mahajan adit...@umich.edu wrote:
 If you want to use eps images, why not just use a white background at
 ConTeXt end (as you had stated in your first message
 
I think you misread: Pol wants the EPS to be white-on-transparent,
instead of black-on-transparent, so that he can use it on a
(dark-)coloured background.
 
That is exactly what I wanted.

Pol stra wrote:
 But your answer gave me the idea to use imegemagick, so I found this
 trick:
...
 The result is good enough for me.
 
Congratulations. Good luck with your work.
 
Thank you

Cheerio,
Sietse
 
  ___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

Re: [NTG-context] Change color of EPS file.

2012-09-14 Thread Troy Henderson
I tested this on a black-on-transparent EPS that was created via MetaPost,
and it seems to work fine.  If you are not using Linux (or Unix or Mac OS
X), let me know and I can probably put together a quick HTML page to do
this on my server.

 cat foo.eps | sed -e s/0 0 0 setrgbcolor/1 1 1 setrgbcolor/g  bar.eps

It simply translates the (0,0,0) triplet (which is black) to the (1,1,1)
triplet (which is white).  This is very simplistic and may not do all that
you want.

Troy Henderson
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

Re: [NTG-context] Change color of EPS file.

2012-09-14 Thread Troy Henderson
I put together this little utility for converting a color EPS/PDF/SVG to
grayscale.

http://www.tlhiv.org/grayscale/

Selecting invert swaps colors from white to black and black to white.
So, using a black/white graphic on a transparent background should
transform it to a white/black graphic on a transparent background.

Testing is certainly necessary.

Troy
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

Re: [NTG-context] Change color of EPS file.

2012-09-14 Thread Aditya Mahajan

On Fri, 14 Sep 2012, Troy Henderson wrote:


I put together this little utility for converting a color EPS/PDF/SVG to
grayscale.

http://www.tlhiv.org/grayscale/

Selecting invert swaps colors from white to black and black to white.
So, using a black/white graphic on a transparent background should
transform it to a white/black graphic on a transparent background.

Testing is certainly necessary.


Interesting. At some stage I might revive the webfilter branch of the 
filler module so that such services can be accessed from within ConTeXt.


See the following post for details: 
http://randomdeterminism.wordpress.com/2010/08/12/using-filters-outside-the-box/


In case anyone is interested, this blog post was talking about code 
available at


https://raw.github.com/adityam/filter/web/t-filter.tex
https://raw.github.com/adityam/filter/web/t-filter.lua

At some stage I decided to delete these features from the filter module 
and move it to a separate module. The code is available at


https://github.com/adityam/context-webfilter

but I haven't used it for about 2 years, and given all the changes in the 
internal namespace, I doubt it will run without modifications. 
Nonetheless, the idea is that a user can use such services using:


\definewebfilter[grayscaleimage]
[prefix={http://www.tlhiv.org/grayscale},
 method=POST,
 ... some other options 
]

and then use

\grayscaleimage{local-image.eps}

This will call the web-service and cache the result.

Aditya
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Change color of EPS file.

2012-09-14 Thread Troy Henderson
For those that care, here is basically how the service works.  The filter
is applied to an SVG, and the uploaded graphic is converted to SVG using
the following process:

EPS - PDF - SVG
PDF - SVG
SVG - PDF - SVG

where the EPS - PDF conversion is done with the standard `epstopdf`
included with TeX.  The PDF - SVG conversion is done with `pdf2svg` which
is available from

http://www.cityinthesky.co.uk/opensource/pdf2svg

and which uses Cairo and Poppler for its conversion.  Now in order for my
simplistic filter to function, all SVG's must essentially look alike
(i.e., come from the same source).  Therefore, uploaded SVG's are converted
to PDF (using Inkscape) and then back to SVG (using `pdf2svg`).  The filter
then works with the resulting SVG and converts it back to the uploaded
format using Inkscape.

Troy
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

Re: [NTG-context] Change color of EPS file.

2012-09-14 Thread luigi scarso
On Sat, Sep 15, 2012 at 1:23 AM, Troy Henderson thend...@gmail.com wrote:


 and which uses Cairo and Poppler for its conversion.  Now in order for my
 simplistic filter to function,

Why 'simplistic' and not 'simple'  ?
I always thought that its meaning is negative (something like 
'simplistic' is a bad imitation of 'simple' )
-- 
luigi
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

Re: [NTG-context] Change color of EPS file.

2012-09-13 Thread Hans Hagen

On 12-9-2012 19:10, pol stra wrote:

Hello,

I have a EPS file wich contains black lines and no background.
The background of my presentation is colored, so I would like to put this 
figure in white.
I tried a \startcolor … \stopcolor environement without succed.

Is there a way to do so?


edit the eps file

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
 | www.pragma-pod.nl
-
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Change color of EPS file.

2012-09-13 Thread Sietse Brouwer
Hello Pol stra,

Off-topic for this mailing list, but on-topic for you: You can do this
with Inkscape.

* Install Inkscape: http://inkscape.org/download/?lang=en
* Open the EPS in Inkscape

Working white-on-white sucks, so
* File  Document properties  click to the right of 'Background:',
below the Default units dropdown
* Choose something nice and pastel-coloured with alpha (opacity) set
to non-zero.

* Select the object
* Object  Ungroup (Ctrl+Shift+G) to make Inkscape see the individual
paths, instead of a single EPS object
The single rectangle selecting the object has now turned into a heap
of rectangles.
* With the colours at the bottom, set the fill to be red with click
and/or set the stroke to be red with Shift+click

This will probably not have the desired effect because some of the
constituent paths will have black fill+transparent stroke, and with
others it will be the other way round. So you'll have to set
fill/stroke individually.

* Select paths in turn, and set their fill/stroke as appropriate.
Their respective values are shown in the bottom left. If you select
multiple paths and their fill/stroke is different, it will be shown as
mixed; when multiple paths' fills/strokes are not mixed they are
identical, and you can change them all at once.

(Depending on ... file-related things ... you may need to use Path 
Object to Path at some point, and possibly Path  Break Apart. But
probably not.)

Good luck!

--Sietse
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Change color of EPS file.

2012-09-13 Thread pol stra

 From: sbbrou...@gmail.com
 Date: Thu, 13 Sep 2012 13:45:20 +0200
 Subject: Re: [NTG-context] Change color of EPS file.
 To: ntg-context@ntg.nl
 CC: r...@hotmail.fr
 
 Hello Pol stra,
 
 Off-topic for this mailing list, but on-topic for you: You can do this
 with Inkscape.
 
 * Install Inkscape: http://inkscape.org/download/?lang=en
 * Open the EPS in Inkscape
 
 Working white-on-white sucks, so
 * File  Document properties  click to the right of 'Background:',
 below the Default units dropdown
 * Choose something nice and pastel-coloured with alpha (opacity) set
 to non-zero.
 
 * Select the object
 * Object  Ungroup (Ctrl+Shift+G) to make Inkscape see the individual
 paths, instead of a single EPS object
 The single rectangle selecting the object has now turned into a heap
 of rectangles.
 * With the colours at the bottom, set the fill to be red with click
 and/or set the stroke to be red with Shift+click
 
 This will probably not have the desired effect because some of the
 constituent paths will have black fill+transparent stroke, and with
 others it will be the other way round. So you'll have to set
 fill/stroke individually.
 
 * Select paths in turn, and set their fill/stroke as appropriate.
 Their respective values are shown in the bottom left. If you select
 multiple paths and their fill/stroke is different, it will be shown as
 mixed; when multiple paths' fills/strokes are not mixed they are
 identical, and you can change them all at once.
 
 (Depending on ... file-related things ... you may need to use Path 
 Object to Path at some point, and possibly Path  Break Apart. But
 probably not.)
 
 Good luck!
 
 --Sietse

Thanks Sietse

I already tried the inskape way, but it’s too much work if you have many files 
to proced.
But your answer gave me the idea to use imegemagick, so I found this trick:
convert -background none -density 300 -negate a1.EPS bbb.png
I do not know why, but the same command with an EPS output gives me a white 
background so I had use a png file.
The result is good enough for me.
Thanks again
  ___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

Re: [NTG-context] Change color of EPS file.

2012-09-13 Thread Aditya Mahajan

On Thu, 13 Sep 2012, pol stra wrote:




Off-topic for this mailing list, but on-topic for you: You can do this
with Inkscape.

* Install Inkscape: http://inkscape.org/download/?lang=en
* Open the EPS in Inkscape

Working white-on-white sucks, so
* File  Document properties  click to the right of 'Background:',
below the Default units dropdown
* Choose something nice and pastel-coloured with alpha (opacity) set
to non-zero.

* Select the object
* Object  Ungroup (Ctrl+Shift+G) to make Inkscape see the individual
paths, instead of a single EPS object
The single rectangle selecting the object has now turned into a heap
of rectangles.
* With the colours at the bottom, set the fill to be red with click
and/or set the stroke to be red with Shift+click

This will probably not have the desired effect because some of the
constituent paths will have black fill+transparent stroke, and with
others it will be the other way round. So you'll have to set
fill/stroke individually.

* Select paths in turn, and set their fill/stroke as appropriate.
Their respective values are shown in the bottom left. If you select
multiple paths and their fill/stroke is different, it will be shown as
mixed; when multiple paths' fills/strokes are not mixed they are
identical, and you can change them all at once.

(Depending on ... file-related things ... you may need to use Path 
Object to Path at some point, and possibly Path  Break Apart. But
probably not.)

Good luck!

--Sietse


Thanks Sietse

I already tried the inskape way, but it’s too much work if you have many files 
to proced.
But your answer gave me the idea to use imegemagick, so I found this trick:
convert -background none -density 300 -negate a1.EPS bbb.png
I do not know why, but the same command with an EPS output gives me a white 
background so I had use a png file.
The result is good enough for me.


If you want to use eps images, why not just use a white background at 
ConTeXt end (as you had stated in your first message).


Aditya___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

Re: [NTG-context] Change color of EPS file.

2012-09-13 Thread Sietse Brouwer
Aditya Mahajan adit...@umich.edu wrote:
 If you want to use eps images, why not just use a white background at
 ConTeXt end (as you had stated in your first message

I think you misread: Pol wants the EPS to be white-on-transparent,
instead of black-on-transparent, so that he can use it on a
(dark-)coloured background.

Pol stra wrote:
 But your answer gave me the idea to use imegemagick, so I found this
 trick:
...
 The result is good enough for me.

Congratulations. Good luck with your work.

Cheerio,
Sietse
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


[NTG-context] Change color of EPS file.

2012-09-12 Thread pol stra
Hello,

I have a EPS file wich contains black lines and no background.
The background of my presentation is colored, so I would like to put this 
figure in white.
I tried a \startcolor … \stopcolor environement without succed.

Is there a way to do so?

In last resort I can put a white background with:
\placefigure[left,none]{caption}{\externalfigure[demo-b][background=color,backgroundcolor=white]}

Best regards

  ___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___