Felipe's approach didn't work for me, but I came up with this:

#!/usr/bin/env python
# -*- Encoding: UTF-8 -*-

import minecart

colors = set()

with open("file.pdf", "rb") as file:
    document = minecart.Document(file)
    page = document.get_page(0)
    for shape in page.shapes:
        if shape.fill:
            colors.add(shape.fill.color.as_rgb())

for color in colors: print color

This will print a neat list of all unique RGB values in the first page of your document (you could extend it to all pages, of course).

Answer from 黄雨伞 on Stack Overflow
🌐
PyMuPDF
pymupdf.readthedocs.io › en › latest › colors.html
Color Database - PyMuPDF documentation
We have taken the liberty to copy this database (a list of tuples) modified into PyMuPDF and make its colors available as PDF compatible float triples: for wxPython’s (“WHITE”, 255, 255, 255) we return (1, 1, 1), which can be directly used in color and fill parameters.
🌐
Readthedocs
colour.readthedocs.io › en › v0.3.8
Colour Science for Python — Colour 0.3.8 documentation
Colour is a Python colour science package implementing a comprehensive number of colour theory transformations and algorithms.
Discussions

How to detect color from PDF Python - Stack Overflow
Is there any way, in Python, of automatically detect the colors in a certain area of a PDF and either translate them to RGB or compare them to the legend and then get the color? More on stackoverflow.com
🌐 stackoverflow.com
Scraping Data and Colors from PDF Using Python
read this: http://stackoverflow.com/questions/29342542/how-can-i-extract-a-javascript-from-a-pdf-file-with-a-command-line-tool PDF is not an easy beast to tame. More on reddit.com
🌐 r/Python
2
9
March 31, 2017
How to make a colour composite image in python?
I think those tutorials are pretty much what you need. In the end there are many possible ways how to get there, but essentially you'll always have to generate the [R,G,B] values for each pixel and plot that. If you do plt.imshow() of the data of a single fits (taken in one filter) that will be monochrome of course. It might actually already work if you just overplot the different filter images using imshow with different color maps ("Reds"/"Greens"/"Blues"), you can use the cmap=... argument that imshow has. More on reddit.com
🌐 r/astrophysics
14
5
May 22, 2025
My first Python Library : SecretColors

You need to add images to the github page: you wont get any users with text about a color palette.

More on reddit.com
🌐 r/Python
15
33
November 18, 2019
🌐
Python
docs.python.org › 3 › library › colorsys.html
colorsys — Conversions between color systems
More information about color spaces can be found at https://www.poynton.ca/pdf/ColourFAQ.pdf and https://www.cambridgeincolour.com/tutorials/color-spaces.htm. The colorsys module defines the following functions: colorsys.rgb_to_yiq(r, g, b)¶ · Convert the color from RGB coordinates to YIQ coordinates.
🌐
Readthedocs
colour.readthedocs.io › en › v0.3.11
Colour Science for Python — Colour 0.3.11 documentation
Colour is a Python colour science package implementing a comprehensive number of colour theory transformations and algorithms.
🌐
Colour Science
colour-science.org
Colour Science for Python | Colour Science
Colour is an open-source Python package providing a comprehensive number of algorithms and datasets for colour science.
🌐
Achim Zeileis
zeileis.org › news › python_colorspace
colorspace: A Python toolbox for colors and palettes
July 30, 2024 - Python package 'colorspace' with tools for manipulating and assessing colors and palettes is now available from PyPI, accompanied by a documentation web page and an arXiv paper.
Find elsewhere
🌐
GitHub
github.com › colour-science › colour
GitHub - colour-science/colour: Colour Science for Python · GitHub
Colour is an open-source Python package providing a comprehensive number of algorithms and datasets for colour science.
Author: colour-science
🌐
PyPI
pypi.org › project › colour
colour · PyPI
converts and manipulates various color representation (HSL, RVB, web, X11, ...)
🌐
ResearchGate
researchgate.net › publication › 390453330_GCol_A_High-Performance_Python_Library_for_Graph_Colouring
(PDF) GCol: A High-Performance Python Library for Graph Colouring
April 2, 2025 - PDF | On Apr 2, 2025, Rhyd Lewis and others published GCol: A High-Performance Python Library for Graph Colouring | Find, read and cite all the research you need on ResearchGate
🌐
PyPI
pypi.org › project › colour-science
colour-science · PyPI
Colour is an open-source Python package providing a comprehensive number of algorithms and datasets for colour science.
🌐
Colour-science
colour-science.org › api › 0.3.3 › html
Colour Science for Python — Colour 0.3.3 documentation
Colour is a Python colour science package implementing a comprehensive number of colour theory transformations and algorithms · It is open source and freely available and under the New BSD License terms
🌐
Michael Currin
michaelcurrin.github.io › dev-cheatsheets › cheatsheets › python › libraries › colors.html
Colors | Dev Cheatsheets
>>> from colour import Color >>> c = Color("blue") >>> c <Color blue> >>> c.hex '#00f' >>> c.hsl (0.66..., 1.0, 0.5) >>> c.rgb (0.0, 0.0, 1.0)
Author: vaab
🌐
Scientific-python
blog.scientific-python.org › matplotlib › pypalettes
Blog - PyPalettes: all the colors you'll ever need
April 1, 2025 - Matplotlib is the go-to library for data visualization in Python. While it offers quality built-in colormaps like viridis and inferno, the limited selection can make Matplotlib charts look similar. To address this, I developed pypalettes, a Python library with over 2,500 high-quality, pre-made color palettes, based on Paletteer.
🌐
GitHub
github.com › fredyshox › PDFColorSwap
GitHub - fredyshox/PDFColorSwap: PDF color conversion tool. · GitHub
PDFColorSwap is a command line tool for color conversion of PDF files written in python.
Author: fredyshox
🌐
pytz
pythonhosted.org › pycolors
PyColors’s documentation — PyColors v0.1.2 documentation
Python module to ease the use of colors on programs that run on CLI. Works fine on Linux and any Operating System running BaSH or compatibles. If the shell’s not color compatible, he’ll get the raw string. The module have predefined some basic colors, but you can use any color, if you know ...
🌐
YouTube
youtube.com › watch
acrylic: An Easy to Use Python Color Library - YouTube
An instroduction to a new color python library: acrylic.
Published: October 1, 2025