PIL rotate image colors (BGR -> RGB)

Claudiu picture Claudiu · Jan 11, 2011 · Viewed 94.1k times · Source

I have an image where the colors are BGR. How can I transform my PIL image to swap the B and R elements of each pixel in an efficient manner?

Answer

Peter9192 picture Peter9192 · Sep 1, 2016

I know it's an old question, but I had the same problem and solved it with:

img = img[:,:,::-1]