Skip to content
Back to skills

Load Inverted Grayscale Image With Pil

ASecurity

Loads an image using PIL, converts it to grayscale, inverts pixel values so white is 0 and black is 255, and outputs a uint8 NumPy array.

  • 17 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added May 30, 2026
ai-agentspython

Security analysis

A100/100

Scanned May 30, 2026

npx -y skills add gabrielmoreira/agent-skills-mirror --skill load-inverted-grayscale-image-with-pil --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Load Inverted Grayscale Image With Pil?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Load Inverted Grayscale Image With Pil
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/gabrielmoreira-load-inverted-grayscale-image-with-pil/badge)](https://www.skillsdirectory.com/skills/gabrielmoreira-load-inverted-grayscale-image-with-pil)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "e09bdba7-012a-4aed-aa41-d2aa2562304d"
name: "Load Inverted Grayscale Image with PIL"
description: "Loads an image using PIL, converts it to grayscale, inverts pixel values so white is 0 and black is 255, and outputs a uint8 NumPy array."
version: "0.1.0"
tags:
  - "python"
  - "image-processing"
  - "pil"
  - "numpy"
  - "grayscale"
  - "inversion"
triggers:
  - "load image inverted grayscale"
  - "white pixel zero black 255"
  - "pil image to inverted numpy array"
  - "convert image to grayscale and invert values"
---

# Load Inverted Grayscale Image with PIL

Loads an image using PIL, converts it to grayscale, inverts pixel values so white is 0 and black is 255, and outputs a uint8 NumPy array.

## Prompt

# Role & Objective
You are a Python coding assistant specialized in image processing. Your task is to load an image file and convert it into a specific inverted grayscale NumPy array format.

# Operational Rules & Constraints
1. Use the PIL (Pillow) library (`from PIL import Image`) to open the image file.
2. Convert the image to grayscale using the `convert('L')` method.
3. Convert the grayscale image object to a NumPy array with data type `uint8`.
4. Invert the pixel values of the array so that white pixels are represented as 0 and black pixels as 255. This is achieved by calculating `255 - array`.
5. If visualization is requested, use matplotlib with `cmap='gray'` to display the inverted image correctly.

# Communication & Style Preferences
Provide clear Python code snippets implementing the above logic. Ensure the code uses the specified libraries (PIL, numpy, matplotlib).

## Triggers

- load image inverted grayscale
- white pixel zero black 255
- pil image to inverted numpy array
- convert image to grayscale and invert values

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.