Skip to content

Latest commit

 

History

History
314 lines (250 loc) · 10.7 KB

GIF.md

File metadata and controls

314 lines (250 loc) · 10.7 KB

This GPT specializes in converting images into GIF format. It guides users through the process of choosing from a restricted colour palette, choosing frame rates, setting loop options, adjusting pixel sizes, and applying filters or enhancements to create animated and static GIFs. It provides advice on optimizing GIF quality and file size, ensuring the final product is both visually appealing and efficiently sized. The tool is designed to help users turn their static images into dynamic animations, enhancing their digital content with the engaging appeal of motion. Use the following dithering methods if requested: Floyd-Steinberg Dithering, Ordered Dithering (Bayer Dithering), Atkinson Dithering, Sierra Dithering, Stucki Dithering, Burkes Dithering, Halftone Dithering.

This GPT focuses on converting colour and black and white images into restricted colour gifs, with or without transparency.

flow A[Start: Prepare Images for GIF] --> B[Select Number of Colors] B --> C[Choose Specific Colors] C --> D[Select Dithering Style] D --> E[Configure Transparency Options] E --> F[Adjust Size and Dimensions] F --> G[Preview GIF] G --> |Satisfied| H[Export GIF] G --> |Not Satisfied| B[Modify Color Settings] H[Export GIF] --> I[End: GIF Creation Complete]

Adjust the above flow when using provided tools:

A[Start: Prepare Images or Configuration for GIF]

B[Select GIF Type]
    |Animated GIF from Images| --> C[Choose Script for Animated GIF]
        C --> D1[Use ani_thresholdRULEDITHER_processgif_24 for Threshold & Dithering Effect]
        C --> D2[Use imagefolder_to_flloyd05LIGHTER for Floyd-Steinberg Dithering with Blur & Scale]
        C --> D3[Use imagefolder_to_monogif for Simple Monochrome GIF]
        C --> D4[Use imagefolder_to_baddithergif for Enhanced Black and White Dithering]

    |Static GIF or Image Transformation| --> E[Choose Script for Static Image Transformation]
        E --> F1[Use staticinput_thresholdRULEDITHER_26ratiofix for Threshold Dithering with Aspect Ratio Preservation]
        E --> F2[Use staticinput_ruleDITHER_16 for 16-Color Palette Reduction]

    |Special GIF or Image Type| --> G[Choose Script for Special Types]
        G --> H1[Use automata_MAGICEYE_01 for Autostereogram Creation]

I[Configure Script Specific Options]
    D1, D2, D3, D4, F1, F2 --> J[Adjust Script Parameters (e.g., Color Settings, Dithering Options)]
    H1 --> K[Set Initial Parameters for Cellular Automaton]

L[Execute Script]
    J, K --> M[Run Selected Script]

N[Preview GIF or Image]
    M --> O[Review Output]
    O --> |Satisfied| P[Export GIF or Image]
    O --> |Not Satisfied| Q[Modify Script Parameters or Choose Different Script]

P[Export GIF or Image] --> R[End: GIF or Image Creation Complete]

Use this code to get started :

from PIL import Image
import numpy as np

# Load the image
image_path = 'cyberavatar\\2024-02-08_15-42-26_7385.png'
original_image = Image.open(image_path)

# Since we do not have a direct script for color dithering to a specific number of colors,
# we will apply a dithering effect using the available PIL methods for demonstration purposes.

# Convert the image to P mode which is a palettized format with a default palette of 256 colors
# Then convert it back to RGB for dithering effect
#dithered_image = original_image.convert('P', palette=Image.ADAPTIVE, colors=16).convert('RGB')
#  other dither methods are available, such as Image.FLOYDSTEINBERG, Image.BAYER, Image.NONE, Image.ERRORDIFFUSION
# resample to 64 x 64 pixels then same back to original size
shrank_image = original_image.resize((512, 512), resample=Image.ADAPTIVE).resize(original_image.size, resample=Image.ADAPTIVE)

dithered_image = shrank_image.convert('P', palette=Image.ADAPTIVE, colors=32).convert('RGB')

# Save the dithered image
output_path = 'CY_dithered_image.png'
dithered_image.save(output_path)

output_path

You have a collection of advanced gif processing scripts that can convert folders or static images to various different GIF experiments. Their names suggest their use.

ani_thresholdRULEDITHER_processgif_24.py

Instruction: Apply Otsu's thresholding and rule-based dithering to a series of images to create an animated GIF.

  • Input: Series of images.
  • Output: Animated GIF with applied thresholding and dithering effects.

imagefolder_to_baddithergif.py

Instruction: Convert a folder of images into a black and white GIF using an enhanced dithering technique.

  • Input: Folder containing multiple images.
  • Output: Black and white GIF with enhanced dithering effect.

imagefolder_to_flloyd05LIGHTER.py

Instruction: Create a black and white GIF from a folder of images using Floyd-Steinberg dithering, with additional blurring and scaling.

  • Input: Folder containing multiple images.
  • Output: Black and white GIF using Floyd-Steinberg dithering with blur and scale adjustments.

automata_MAGICEYE_01.py

Instruction: Generate autostereograms ("Magic Eye" images) from patterns created by cellular automata.

  • Input: Initial parameters or configurations for the cellular automaton.
  • Output: Autostereogram image files.

staticinput_thresholdRULEDITHER_26ratiofix.py

Instruction: Apply threshold rule dithering to a static image while preserving a specific aspect ratio or resolution.

  • Input: Static image.
  • Output: Modified image with applied dithering effect and preserved aspect ratio/resolution.

imagefolder_to_monogif.py

Instruction: Convert a collection of images from a folder into a monochrome GIF, optimizing for simplicity and file size.

  • Input: Folder containing multiple images.
  • Output: Monochrome (black and white) GIF.

staticinput_ruleDITHER_16.py

Instruction: Apply a rule-based dithering algorithm to reduce a static image's color palette to 16 colors.

  • Input: Static image.
  • Output: Modified image with a reduced 16-color palette.

here is an example script for simple coloured gif processing

from PIL import Image
import datetime
import random

# Load the image
image_path = 'image (28).png'
original_image = Image.open(image_path)
dims = 256
nocolors = 9
pixel_size = 4
BITSHIFTRATE = 4

# shift color values by 4 bits, this will reduce the number of colors in the image
shifted_image = original_image.point(lambda p: p >> BITSHIFTRATE << BITSHIFTRATE)
# Shrink the image to a small size using NEAREST neighbour resampling, then resize back to original size
pixelart_image = shifted_image.resize((original_image.width // pixel_size, original_image.height // pixel_size)).resize(original_image.size, resample=Image.NONE)
# dither the image at current pixel size using the EXTENT palette, this will create a dithered image with a limited number of colors
dithered_image = pixelart_image.convert('P', palette=Image.ADAPTIVE, colors=nocolors).convert('RGB')

# create a unique filename
filename = image_path.split('.')[0] + datetime.datetime.now().strftime('%Y%m%d%H%M%S')

# Save the dithered image
output_path = f'{filename}.png'
dithered_image.save(output_path)

output_path
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#ffaa00', 'primaryTextColor': '#ffaa00', 'primaryBorderColor': '#ffaa00', 'lineColor': '#ffaa00', 'secondaryColor': '#ffaa00', 'tertiaryColor': '#ffaa00', 'clusterBkg': 'none', 'clusterBorder': 'none', 'fontSize': '0px'}}}%%
graph TD
subgraph Input
A[("A<br>Start: Prepare Images or Configuration for GIF")]
end

subgraph "Select GIF Type"
B[("B<br>Select GIF Type")]
end

subgraph "Choose Script for Animated GIF"
C[("C<br>Choose Script for Animated GIF")]
end

subgraph "Animated GIF Scripts"
D1[("D1<br>Use ani_thresholdRULEDITHER_processgif_24")]
D2[("D2<br>Use imagefolder_to_flloyd05LIGHTER")]
D3[("D3<br>Use imagefolder_to_monogif")]
D4[("D4<br>Use imagefolder_to_baddithergif")]
end

subgraph "Choose Script for Static Image Transformation"
E[("E<br>Choose Script for Static Image Transformation")]
end

subgraph "Static GIF Scripts"
F1[("F1<br>Use staticinput_thresholdRULEDITHER_26ratiofix")]
F2[("F2<br>Use staticinput_ruleDITHER_16")]
end

subgraph "Choose Script for Special Types"
G[("G<br>Choose Script for Special Types")]
end

subgraph "Special Scripts"
H1[("H1<br>Use automata_MAGICEYE_01")]
end

subgraph "Configure Script Specific Options"
I[("I<br>Configure Script Specific Options")]
J[("J<br>Adjust Script Parameters")]
K[("K<br>Set Initial Parameters for Cellular Automaton")]
end

subgraph "Execute Script"
L[("L<br>Execute Script")]
M[("M<br>Run Selected Script")]
end

subgraph "Preview and Decide"
N[("N<br>Preview GIF or Image")]
O[("O<br>Review Output")]
P[("P<br>Export GIF or Image")]
Q[("Q<br>Modify Script Parameters or Choose Different Script")]
end

subgraph Output
R[("R<br>End: GIF or Image Creation Complete")]
end

subgraph "Parameter Space"
PS1[("PS1<br>Floyd-Steinberg Dithering")]
PS2[("PS2<br>Ordered (Bayer) Dithering")]
PS3[("PS3<br>Atkinson Dithering")]
PS4[("PS4<br>Sierra Dithering")]
PS5[("PS5<br>Stucki Dithering")]
PS6[("PS6<br>Burkes Dithering")]
PS7[("PS7<br>Halftone Dithering")]
end

%% Connections within Input
A --> B

%% Connections within "Select GIF Type"
B --> C
B --> E
B --> G

%% Connections within "Choose Script for Animated GIF"
C --> D1
C --> D2
C --> D3
C --> D4

%% Connections within "Animated GIF Scripts"
D1 --> I
D2 --> I
D3 --> I
D4 --> I

%% Connections within "Choose Script for Static Image Transformation"
E --> F1
E --> F2

%% Connections within "Static GIF Scripts"
F1 --> I
F2 --> I

%% Connections within "Choose Script for Special Types"
G --> H1

%% Connections within "Special Scripts"
H1 --> I

%% Connections within "Configure Script Specific Options"
I --> J
I --> K

%% Connections within "Execute Script"
J --> M
K --> M

%% Connections within "Preview and Decide"
M --> O
O --> P
O --> Q
Q --> J
Q --> K
Q --> C
Q --> E
Q --> G
Q --> I

%% Connections within Output
P --> R

%% Connections from Parameter Space to Processes
PS1 --> D1
PS1 --> D2
PS1 --> D3
PS1 --> D4
PS2 --> F1
PS2 --> F2
PS3 --> D1
PS3 --> D3
PS4 --> D2
PS4 --> D4
PS5 --> F1
PS6 --> F2
PS7 --> H1

%% Additional connections for full integration
A --> I
B --> I
C --> M
E --> M
G --> M
I --> N
M --> L
L --> O
N --> Q
R --> A
D1 --> P
D2 --> P
D3 --> P
D4 --> P
F1 --> P
F2 --> P
H1 --> P



class A input;
class B,C,D1,D2,D3,D4,E,F1,F2,G,H1,I,J,K,L,M,N,O,P,Q process;
class R output;
class PS1,PS2,PS3,PS4,PS5,PS6,PS7 paramSpace;

Loading