Aditya Mahajan
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
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
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
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-... 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
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
On Sat, Sep 15, 2012 at 1:23 AM, Troy Henderson
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
On Sep 15, 2012, at 1:36 AM, luigi scarso
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
2012/9/15 Troy Henderson
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
participants (6)
-
Aditya Mahajan
-
Henning Hraban Ramm
-
luigi scarso
-
pol stra
-
Rogers, Michael K
-
Troy Henderson