Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImageMagick: write pixels in BGR order

Tags:

imagemagick

I want to convert (a lot of) JPEG images to the Sun Raster format (see here for instance), because my program can only use this format.

The issue is that my program only allows images of type Old or Standard i.e. with pixel written in the BGR order. (I should change that but don't have the time). By default, ImageMagick generates files in the RGB format.

I have found a trick to swap the color planes, but as the file is style written as RGB I get fancy colors.

This is probably a simple option to pass to ImageMagick, but I didn't find it. Do you have an idea?

like image 501
Mathieu Dubois Avatar asked Dec 04 '22 07:12

Mathieu Dubois


1 Answers

Another way to swap colors is to use the -color-matrix option. For example, to convert RGB to BGR:

convert input.png -color-matrix '0 0 1
                                 0 1 0
                                 1 0 0' output.png

Reference: http://www.imagemagick.org/Usage/color_mods/

like image 156
Charles Avatar answered Apr 06 '23 01:04

Charles