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


#1

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.


#2

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


#3

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


#4

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?.


#5

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.


#6

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.

#7

"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


#8

@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:


#9

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.


#10

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?)