Skip to content

Instantly share code, notes, and snippets.

@SeyedAbdollahi
Created December 5, 2021 20:05
Show Gist options
  • Save SeyedAbdollahi/c4c831b58d25a960a45f6157415cbc26 to your computer and use it in GitHub Desktop.
Save SeyedAbdollahi/c4c831b58d25a960a45f6157415cbc26 to your computer and use it in GitHub Desktop.
Example of negative of an image with Python and Pygame
import pygame
img = pygame.image.load('F:\input1.jpg')
W, H = img.get_width(), img.get_height()
for x in range(W):
for y in range(H):
color = pygame.Surface.get_at(img, (x,y))
color = ~color
pygame.Surface.set_at(img, (x,y), color)
pygame.image.save(img, 'F:\output.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment