Reputation: 761
I want to generate color palette from an image but FFmpeg allows to generate palettes only from videos. The only Bash tool I know that can generate color palettes from images is ImageMagick, but it generates palettes in a *.txt
and I need a *.png
palette.
Is there a bash tool to generate palettes with fine control? Or maybe there is a way to do it in FFmpeg?
P.S. I need that palette to create GIF in FFmpeg.
Upvotes: 3
Views: 4960
Reputation: 2433
You can generate palette from PNG with ffmpeg. Try this:
ffmpeg -i target.png -vf palettegen palette.png
Upvotes: 4
Reputation: 5299
Sometimes you have to do some extra work as most software has limits. For example you say "but it generates palettes in a *.txt and I need a *.png palette. " well you are half way there. Use the text output to create a png image. There are a few posts on the imagemagick forum about it and here is one: http://wizards-toolkit.org/discourse-server/viewtopic.php?t=25478
list=`convert beach.jpg +dither -colors 5 -unique-colors txt:- | tail -n +2 | sed -n 's/^.*\#.* \(.*\).*$/xc\:\1/p'`
convert -size 50x50 $list -append palette.png
There was a thread about colour pallets from different software giving different results which is something to beware of.
Upvotes: 1