add tag
10 months ago samcarter

Background: my git client allows to choose an icon for each repository, which makes it easier to recognise them in an overview. To do this one simply places a graphic with the name “icon” or “logo” in folder of the repository. Allowed file formats are .tiff, .png, .jpg, .gif, or icns. I thought it would be nice to have document automatically create such a file with the theme colour of the document.


In addition to creating a document, I would also like to also create a separate pixel graphic which is a simple square filled with a solid colour. The colour is defined in the preamble of the document. How can I do this?

A simple MWE as starting point:

Top Answer
10 months ago samcarter

Using the colour conversion/extraction from https://tex.stackexchange.com/q/436012/36296 one can then for example pass the extracted colour to image magick to create a pixel graphic:

Answer #2
10 months ago samcarter

It is probably silly to use TikZ to create a simple square, but one can use the external library for this:

10 months
samcarter replying to Skillmon — Friday, 20th Sep 2024 10:15

That would probably the fastest solution, but I will have to think about how to convert the colour to rgb or similar and then pass it to a system call.

15 hours
Skillmon replying to samcarter — Thursday, 19th Sep 2024 19:40

If I enabled shell escape anyway, I’d most likely take the route to directly call magick

Skillmon replying to samcarter — Thursday, 19th Sep 2024 19:40

well, shell escape, or writing it in a temporary file that you evaluate in your shell.

samcarter replying to Skillmon — Thursday, 19th Sep 2024 19:31

Drawing the square isn’t really the problem, but how to get the colour out of the main document? With tikz externalise, this does all the magic, but it seems rather overkill.

I could also directly use magick -size 100x100 xc:rgb\(255,216,1\) whatever.png on the command line, but then I again have the problem to get the colour.

32 minutes
Skillmon — Thursday, 19th Sep 2024 18:59

@samcarter, re: your question, well, if you want to create more than a single pixel you could use pxpic or PixelArt or PixelArtTikz. If you only need to draw a simple square then \textcolor{duck}{\rule{1pt}{1pt}}, question is how to create a PNG or similar from this. You could let CI do that, or start an extarnal program like you do in TikZ in your answer.

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.