Can I create .eps (or tiff) images directly in Racket?

I am using plot to save plots as .svg and .png, but need to get .eps or .tiff formats. I haven't found a function that exports to either of these in Racket -- only Neil's mediafiles deals with .tiff for metadata purposes.

My current work-flow is therefore to create .svg and then convert them with some online website. Any suggestions how to do that?

1 Like

Do you need compressed .tiff or uncompressed .tiff are good enough? The .tiff files can have very different representations of the image inside and in particular there is one uncompressed versions that is straigforward (but the file is big).

(I used uncompressed .tiff a long time ago, in another language, so I don't remember the details. It was something like a header with the size and magic numbers, the pixels in RGB or RGBA and some footer.)

1 Like

The racket/draw library has support for EPS via post-script-dc%.

In fact, based on a brief look at the plot code, I think if you use .ps as the extension (or select 'ps as the image type), plot-file actually creates an EPS file. (I haven't tested this, though.)


I would consider the ImageMagik library, which can convert between many file format. There's a binding to lots of the library as an example here: racket/magick.rkt at master · racket/racket · GitHub


I can't offer an eps solution, but MetaPict has an save-pict-to-pdf and I expect you need to make minimal changes in order to get eps instead:


Both the solution by @ryanc and @samth work, although I didn't try the ffi route for imagemagick, using it on the command line directly. For anyone trying this out and getting ImageMagick permission errors (on Ubuntu), check this: Trouble with batch conversion of .png to .pdf using convert - Ask Ubuntu.

The one thing I am not sure about is whether the .eps file is a vector file or not, but I don't know if it matters. I'll find out when the editor gets back to me.

My guess is that @soegaard's solution also works, but one probably needs to directly use the post-script-dc% mentioned by @ryanc, since pdf-dc% discards the #:as-eps argument.

@gus-massa: since I am Ubuntu and got .eps working, I'll ignore .tiff (I don't need both formats).

EPS is a vector format. It stands for Encapsulated PostScript and PostScript was
the precursor for PDF. I remember using it before pdflatex entered the scene.

Yes, I know - but apparently EPS can also contain rasterized content, which (if I understood correctly from the various Stack Overflow questions and answers) might play badly with transforming it into svg. (See for example php - Check if a file contains raster or vector elements? (pdf, eps, ai) - Stack Overflow) I may have misunderstood, and it may not even matter in my use case - I will find out once the copy editor gets back to me.

1 Like

SVG files can contain raster elements as JPEG or PNG images via <image>.

1 Like