This node manipulates the pixel art image in ways that it should look pixel perfect (downscales, changes palette, upscales etc.).
Generate, downscale, change palletes and restore pixel art images with SDXL.
Save a picture as Webp (+optional JPEG) file in Comfy + Workflow loading.
Update 1.5.2:
Update 1.5.1: @tsone added a new dithering node: PixelArtAddDitherPattern
Update 1.5: Maintenance & Dithering + bugfixes
Dithering examples:
Update 1.4: Added a check and installation for the opencv (cv2) library used with the nodes. This should fix the reported issues people were having.
Update 1.3: Updated all 4 nodes. Please, pull this and exchange all your PixelArt nodes in your workflow. Mind the settings.
Update 1.2: PixelArtDetectorConverter will upscale the image BEFORE the pixelization/quantization process if the input image is smaller than the resize sizes. If bigger, it will downscale after quantization.
Update 1.1: changed the default workflow.json to use the default "Save Image" node. workflow_webp.json will be using the webp node.
[!IMPORTANT] If you have an older version of the nodes, delete the node and add it again. Location of the nodes: "Image/PixelArt". I've added some example workflow in the workflow.json. The example images might have outdated workflows with older node versions embedded inside.
Pixel Art manipulation code based on: https://github.com/Astropulse/pixeldetector
This adds 4 custom nodes:
The plugin also adds a script to Comfy to drag and drop generated webp|jpeg files into the UI to load the workflows.
The nodes are able to manipulate the pixel art image in ways that it should look pixel perfect (downscales, changes palette, upscales etc.).
[!IMPORTANT] You can disable the embedded resize function in the nodes by setting W & H to 0.
To use these nodes, simply open a terminal in ComfyUI/custom_nodes/ and run:
git clone https://github.com/dimtoneff/ComfyUI-PixelArt-Detector
I am using a "Save_as_webp" node to save my output images (check the workflow_webp.json). You can find my customization in the following repo (part of the workflow).
Just execute this command in ComfyUI/custom_nodes/ too.
git clone https://github.com/dimtoneff/ComfyUI-Saveaswebp
Original "Save_as_webp" node repo: https://github.com/Kaharos94/ComfyUI-Saveaswebp.
If you don't want to use "Save_as_webp" nodes, just delete them from my workflow in workflow_webp.json and add the default "Save Image" node to save as PNG (or use the default workflow.json)
Restart ComfyUI afterwards.
Use LoRa: https://civitai.com/models/120096/pixel-art-xl
Drag the workflow.json file in your ComfyUI
Set the resize inputs to 0 to disable upscaling in the "Save" node.
Reduce palettes or completely exchange palettes on your images.
Positive prompt: pixelart, {your scene}, pixel-art. low-res, blocky, pixel art style, 8-bit graphics, sharp details, less colors, early computer game art
Negative prompt: sloppy, messy, blurry, noisy, highly detailed, ultra textured, photo, realistic, high-resolution, photo-realistic
on a pixel drawing converting to a pixel asset for finetuning:
Input:
Output:
Workflow WEBP (drag & drop):
Feel free to experiment! Free web tool for pixel art: https://www.pixilart.com/draw
Other image2image examples: Discussion in the issues
There is a compression slider and a lossy/lossless option for webp. The compression slider is a bit misleading.
In lossless mode, it only affects the "effort" taken to compress where 100 is the smallest possible size and 1 is the biggest possible size, it's a tradeoff for saving speed.
In lossy mode, that's the other way around, where 100 is the biggest possible size with the least compression and 1 is the smallest possible size with maximum compression.
There is an option to save a JPEG alongside the webp file.
Included palettes from: https://lospec.com/palette-list
[!IMPORTANT] If you like some palette, download the 1px one and add it to the "ComfyUI-PixelArt-Detector\palettes\1x" directory.
GRIDS
Community examples:
Nodes:
Workflow view:
Here are some palette change examples:
Normal image:
Reduced palette:
Upscaled:
Big thanks to https://github.com/Astropulse/pixeldetector for the main code.
Big thanks to https://github.com/Kaharos94/ComfyUI-Saveaswebp for the webp saving code.
Big thanks to https://github.com/paultron for numpy-ifying the downscale calculation and making it tons faster.
Big thanks to https://lospec.com/palette-list and the creators of the awesome palettes.