Skip to content

FaceSets: Use the correct palette#54

Open
Ghabry wants to merge 1 commit into
EasyRPG:masterfrom
Ghabry:face-flip
Open

FaceSets: Use the correct palette#54
Ghabry wants to merge 1 commit into
EasyRPG:masterfrom
Ghabry:face-flip

Conversation

@Ghabry
Copy link
Copy Markdown
Member

@Ghabry Ghabry commented May 23, 2026

As noticed by @Mimigris the color palette is messed up for the Facesets. Was my fault.

Using imagemagick generated a new palette when flipping the FaceSets.

Redid the flip with a Python script which preserved the original palette.

The solution reminds me a bit of the stuff I do in my Python class when I talk about image processing :D.


Script generated by Gemini Pro 3.1 via this prompt:

For all the png files which have a 4x4 grid of 48x48 faces make them face to the right
without altering their position. Preserve the colour palette.
Use imagemagic or Python Pillow to solve this.

import os
from PIL import Image

def process_images():
    for filename in os.listdir('.'):
        if filename.lower().endswith('.png'):
            filepath = os.path.join('.', filename)
            try:
                with Image.open(filepath) as img:
                    width, height = img.size
                    if width % 48 == 0 and height % 48 == 0:
                        print(f"Processing {filename}...")
                        
                        cols = width // 48
                        rows = height // 48
                        
                        # Create a copy to maintain palette and info
                        new_img = img.copy()
                        
                        for row in range(rows):
                            for col in range(cols):
                                left = col * 48
                                upper = row * 48
                                right = left + 48
                                lower = upper + 48
                                
                                face = img.crop((left, upper, right, lower))
                                face_flipped = face.transpose(Image.FLIP_LEFT_RIGHT)
                                
                                new_img.paste(face_flipped, (left, upper))
                        
                        new_img.save(filepath, format='PNG')
            except Exception as e:
                print(f"Error processing {filename}: {e}")

if __name__ == '__main__':
    process_images()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant