Creates a GIMP .gpl palette file from an image.
GIMP itself includes an import palette feature (Palettes Menu > Import Palette...) that can be used to create palettes from images.
img2gpl IMAGE [PALETTE]
Requires Pillow.
Python script to create a GIMP palette from an image.