Pixel Stats - Check the total amount of colored pixels you used in your art!

Script created by Haloflooder. Idea thought up by CopherNeue

Description

Pixel Stats is a script that tells you the total amount of pixels for each color (outputs the RGB values) along with the percentage. It could be useful for people who are curious about what colors they are using the most for their artwork.

Features

- Analyzes the image and spits out the data about the pixels!
- Lists the colors as a color group (red, orange, blue, etc)
- You also have the ability to analyze part of an image by using the select tool! (But see the bug section first)

Limitation

This script can only get the stats from the current layer you selected. The API isn't flexible enough for the script to get the stats from the entire image. To get the stats for the entire image, you need to flatten the layers to 1 layer.

DISCLAIMER

DO NOT use this script with an image with lots and lots of colors or LARGE images otherwise you will run the risk of crashing Aseprite. Pixel art should be fine for the most part unless you have more than 1000 colors.
Save your project before you use the script!

Bugs

Aseprite crashes if the active layer you selected is only partially full. So there needs to be a background in the layer in order for the script to not crash Aseprite. The bug is caused by Aseprite's scripting ability so this issue cannot be fixed until Aseprite fixes the bug.
The selection feature only works with a single rectangle selection. Wands, polygons, multiple selections, etc won't work since the Aseprite scripting feature is still a WIP.

Requirements

Aseprite version v1.2.9
A text editing tool such as Notepad++, Atom, etc. Also, for the sake of your sanity. Don't use Microsoft Notepad.
And some effort

Installation

Instructions on how to install the script is on this wiki page on github

Download

Download the script from the release page on the github repo

Updates

v1.0

Initial release.

v1.1

"Space Drawing" Pixel art by DogeNut

Added new selection analyzer, grouped color analyzer, and some options in the script. Also optimized some code in the script as well.

13 Likes

Hi @haloflooder there thank you for sharing this information, I was not aware you can add your own scripts with Aseprite, do you think we can do image manipulation via scripts also?

Thanks in advance

1 Like

I looked deeper… now I see that a lot of things can be done with this… D:

1 Like

Hello, it would also be good to calculate the time spent on the work, I mean to inform you about how much time you have spent so far.
Could it be done ?.
Could they do an official function with this information?


Hola, estaría también bien que calculara el tiempo empleado en la obra, quiero decir que te informe sobre cuanto tiempo has invertido hasta ahora.
ÂżPodrĂ­a hacerse?.
ÂżPodrĂ­an hacer una funciĂłn oficial con esta informaciĂłn?.

1 Like

Hey there! I also didn’t know that you can add scripts to Aseprite until I decided to snoop around Aseprite’s github repo a couple days ago.

It is possible to do image manipulation but depending on what you do in the script, you could easily crash Aseprite. I think that might be a reason why the developers decided not to enable scripts by default. I will be making a demo script that contains lots of examples of what you can do with Aseprite. I’ll message you once I get it done :slight_smile:

edit
Just found out that the scripting feature is extremely buggy. I will still release my demo script after I’m done experimenting with scripts but I suggest that no one should use it for production because it will crash Aseprite in many conditions.

edit 2
Here is a demo script that I made for Aseprite. I also made a wiki page on github that talks about how unstable scripts can be and what bugs I’ve discovered with Aseprite’s scripting feature.

1 Like

Hi! Unfortunately, that’s currently not possible at the moment since scripts can’t run in the background. It would be better if the developers of Aseprite implements that feature to the software.


¡Hola! Lamentablemente, actualmente no es posible en este momento, ya que los scripts no se pueden ejecutar en segundo plano. Sería mejor si los desarrolladores de Aseprite implementan esa característica en el software.
1 Like

"Space Drawing" Pixel art by DogeNut

Pixel Stats v1.1 comes with a few new features and some optimized code to help it run a teensy bit faster! I have also included a minified version of a script if you want a smaller file size for some reason.

Get your hot fresh copy here!
(please read the bug section above before you go crazy with it)

New Features

  • Added the ability to only analyze a selection the user made on the image
  • Added a new color analyzer that tells you what color group the pixels are in (with the option to turn it off in the script)
  • Added a few options in the script to help speed up Pixel Stats (just by a little bit)

Other boring changes

  • Optimized the text spacer functions (Runs much faster now!)
  • Added a debug flag to show how long each section runs

For more information about the script, go to this wiki page

3 Likes

@haloflooder
Would it be possible to display a color swatch in the output, rather than a text label describing the color?
Or to output an image with text describing the pixels/percentage?

Example:

2 Likes

Thanks for the suggestion! It’s a pretty good idea but unfortunately, that wouldn’t be possible since I can’t display colors in errors console in 1.2.9.

I can possibly put colors in the Aseprite 1.2.10 but I have to play around with the new gui api first and see what it looks like.

2 Likes

I think that a possible way to report this information (+ colors) would be creating a new image/sprite, I should expose an API to draw text on the canvas and that might be a good start to create the new sprite showing the original sprite stats (or maybe adding more rich text experience to a Dialog textbox, e.g. markdown + images?)

3 Likes

Hello, could you add information on how many maximum colors are there per cell?

I use the division of cells in 8x8 pixels.
I would like to know if any of my cells have more than 3 colors.
Then the script could provide the following information:
Maximum colors in a cell = 4
Then I would discover that there is an error in my drawing.


Hola, ¿podría añadir la información sobre cuantos colores maximos hay por celda?.

Yo uso la division de celdas en 8x8 pixeles.
Me gustaría saber si alguna de mis celdas tiene más de 3 colores.
Entonces el script podrĂ­a proporcionar la informaciĂłn siguiente:
Maximos colores en una celda = 4
Entonces yo descubrirĂ­a que hay un error en mi dibujo.

That’s an interesting idea and it definitely is doable. I looked into supporting multiple cels a few months ago but I didn’t implement it yet since the api was still a work in progress at the time.


Esa es una idea interesante y definitivamente es factible. Investigué el soporte de varias celdas hace unos meses, pero aún no lo implementé ya que la API todavía estaba en progreso en ese momento.
1 Like