4 ms·
> My suggestion is to write a blog post Thank you for your kind advice. But the thing is, I'm not a blogger guy, I've never ever written any blog in my life. I
by skrellm 2mo ago
> My suggestion is to write a blog post
Thank you for your kind advice. But the thing is, I'm not a blogger guy, I've never ever written any blog in my life. If you take a look at my repos, you'll see my focus is on writing code.
Also I honestly don't know what to write.
I've always though that speeding up page load by shrinking images into indexed images is a common knowledge (smaller page = faster page), never occurred to me this needs explaining. I mean, there are already lots of tools for that (tinypng dot com, ImageMagick, pngquant, etc.), it's just neither can handle APNGs, much less animated WebP, so here's paltool to save the day.
As for the algorithms, all I've used (weighted color distance and median cut) has a loooong literature, explaining these much better than I could. I did not invent any of it, these are standard image processing algorithms, although I've used some tricks for better performance and some heuristics to increase output quality.
- gus_massa 2mo agoI was thinking about something simple, like a list of 10 examples with minimal text in between. If you meet with a technical friend to drink a beer, and s/he ask what your project can do, which are the 10 coolest examples that you can show? --- The readme has a few eamples. I'd like a version that shows the explicit command to make the transformation. For example "-D" means decolorize, but I'm not sure how to trigger the recolorize method. Is it "+D"? "-R"? After looking for a while, I think no argument means recolorize but I'm still not sure. Also, they show a strange pallete. I'd prefer a version that shows 1) The original image 2) The exact pallete (or at least a gif/png that shows the exact squares with the colors of the pallete. For example if the pallete has 8 colors, show a 32x4 image with 8 squares 4x4.) 3) The command line 4) The final image --- Perhaps a few examples that show the dithering vs direct quantization would be nice. --- Can your program find the optimal pallete? A long time ago I had to transform a color 256^3 image to a 256 colors image. IIRC I used gimp and paint and perhaps a few more programs. But the palette choice was bad and caused too many quirks. I don't remember how I fixed it. --- A few years ago, my wife wanted a few gif or animals with different colors. I used gimp to find the correct entry in the pallete and then I changed the value of that entry in the pallete directly in the files.
- skrellm 2mo ago> If you meet with a technical friend to drink a beer, and s/he ask what your project can do, which are the 10 coolest examples that you can show? Nothing. This is for those who already understand the benefit of shrinking images and animations using indexed palettes, and just looking for a tool to do it. > I'm not sure how to trigger the recolorize method You can't, that's not part of the tool. You need to implement it in your app that displays such images. That's the whole point. To see recolorization in action, check out one of my other projects here: https://bztsrc.gitlab.io/ludchr/ https://bztsrc.gitlab.io/ludchr/ (select the icons on the right, if a layer has color options, you'll see a pop-up menu with the color variants, clicking on a color will recolorize the layer on-the-fly) > Also, they show a strange pallete. I'd prefer a version that shows That's exactly what the image shows. First figure: original image minus the palette equals decolorized image. Second figure: decolorized image plus palette equals multiple colorized outputs. The palette can be provided in many formats, but the palette on these figures is the actual palette image I've used with paltool. It is an image of 8 x 4 pixels, so it has 4 different gradients. Out of the 8 possible colors in each gradient only 6 used in the example, so the last 2 colors were replaced with a checkerboard on the preview (in the actual palette image these are fully transparent). > A few years ago, my wife wanted a few gif or animals with different colors. I used gimp to find the correct entry in the pallete and then I changed the value of that entry in the pallete directly in the files. That's exactly what decolorization and recolorization is for. I needed this for the ludchr project above. > Can your program find the optimal pallete? No such thing exists, except for pixel art maybe. My program uses multiple methods, calculates scores for each (depending on the distance to the original) and picks the one with the best score. Otherwise it is built around the libimagequant library. https://github.com/ImageOptim/libimagequant https://github.com/ImageOptim/libimagequant The palette might contain fixed colors, and free slots are filled with quantized colors from the image. If the image has no more different colors than the specified maximum, then yes, the palette will be optimal, otherwise you must make peace with some information loss. > A long time ago I had to transform a color 256^3 image to a 256 colors image. IIRC I used gimp and paint and perhaps a few more programs. But the palette choice was bad and caused too many quirks. Yes, that's exactly why I've created this tool. I was also struggling with GIMP (unable to handle alpha channel in palettes) and Imagemagick (unable to handle animated PNGs). My tool does not reinvent the wheel, it just provides an easy to use interface (CLI as well as a free web-service) around already existing and known to work methods.