0

I want the resulting PNG file to have the exact same palette as the input file.

I tried things like:

convert $INPUT -crop 8x32+10+10 -depth 8 $OUTPUT
convert $INPUT -crop 8x32+10+10 -remap $INPUT $OUTPUT
convert $INPUT -crop 8x32+10+10 -define png:preserve-colormap=true $OUTPUT

without luck

Btw, as a workaround, ffmpeg does the job:

ffmpeg -i $INPUT -vf "crop=8:32:0:0" $OUTPUT
Pedro L.
  • 7,376
  • 3
  • 25
  • 27
  • When you crop an image, you select a different set of pixels that may use less of the original palette. So the palette will change. If you want to re-use the same palette, then save the unique-colors to a new image and use -remap to recolonize the image to the original palette. See -remap at https://legacy.imagemagick.org/Usage/quantize/#web_safe – fmw42 May 21 '21 at 17:56
  • Maybe you could share the input image so folks can experiment... – Mark Setchell Jun 20 '21 at 13:46

0 Answers0