How I work with Love Nikki images.

I think this would be a helpful thing for some people, so I will rant openly.

My phone saves Love Nikki images as a lossless PNG. The file size really gets driven up. It gets driven up to about 2 megabytes, and sometimes 5 megabytes if there is a lot of detail it is trying to capture. On top of that, my phone has a “full resolution” mode that goes to 1440x2975 dimensions. The normal resolution, “hd resolution” is 1080x2231. For that reason I have my phone set to hd resolution for most screenshots.

Screenshot_20231220-114018

This is 1080x2231 dimensions. There is no background, so she saves at 600KB. I want to note here, that every object in Love Nikki is saved as a 256 color palette. The colors are usually under 256, but the limit for a palette is 256. This has to do with bits for storing information. In particular, eight bits. 2 to the eighth power is 256, and that is as much math as I can do. Since all these objects are layered in paletted parts, with alpha compositing blending to make new colors, the truth is that these are very limited color variations, even if it has to be saved as truecolor in order to render the accurate style.

Even so, it is normal for phones to save as a JPEG, and it is Love Nikki’s default screenshot option to save as a JPEG. The beautiful intricate color ditherings of each piece can be approximated in DCT patches with color subsampling. It is a very lovely approximation of the original truecolor image. The subsampling does not visibly damage the original color variation, as it was already so few in colors anyway.

LNDUQ is color-reduced with sharp edges

I’m going to continue working with this image. Using the command…

magick identify -format %k Screenshot_20231220-114018.png

….the console will tell me that the full image has 79092 colors. You can see why a PNG is not so bad for a Love Nikki image. I will not hold back—I use cjpeg_hdr to make Love Nikki jpegs this year.

cjpeg_hdr Screenshot_20231220-114018.png Screenshot_20231220-114018.jpg 1

The subspampled colors are revealed if I repeat the earlier command on the resulting jpeg.

colors_received.png
I have 54825 colors after JPEG sampling, compared to 79092 before. This subsampling is very useful. No one will miss all those other colors. But you see, the reason why I like the PNG is that it keeps the edges okay. Love Nikki is already reducing colors in your set pieces so it can load it into the game. By the way, Love Nikki assets are usually saved as PNG, and they’re usually locked away in KTX files, which is just a container for the PNG.

Here is Debbie. She is a good example of a palette character sprite in Love Nikki. All the early sprites were amazing and didn’t have weird errors with them. (I just discovered in Ransa’s default sprite, the image was downscaled from her original palette and the resample from the downscale added colors)

magick identify -format %k debbie_2.png
257

debbie_2

Remarkable, right?! She is clearly a palette, but she is saved as 257 colors! Well, that’s because her palette was possibly, possibly, according to me, superimposed over a much more accurate alpha channel. But she is 166KB, even as PNG type Truecolor + Alpha. Very small, like all sprites in Love Nikki.

Here I show you her alpha channel. Even her alpha channel was reduced in color variation. It is very beautiful and clever, and this is how all Love Nikki assets are simplified in terms of transparency.

magick debbie_2.png -extract alpha debbie_2_a.png

debbie_2_a

(Although, if you find some crazy layered background items, you will see there is sooo much variation in transparency, that they will make the asset exceed Debbie’s size twenty-fold!)

Libjxl reference encoder in the Windows console

I have illustrated, slightly at least, how Love Nikki benefits greatly from the PNG edges with color dithering and reduction. When you have a lossless phone like mine, you want to save the files in a beautiful, faithful way.

What I do is I use the reference encoder for jpegxl. That is the absolutely bestest option. That is not to say that JPEG will do a poor job. Overall, though, take it from me— your options for saving Love Nikki photos range from these popular to obscure image formats~

I discovered DJVU this past month, and it has taken my breath away! I feel that anyone else would find it quite intriguing as well.

But anyway, I found really smooth results with all of these. But JXL is objectively the best, and it is best for the reason that I have been getting at: Love Nikki has reduced colors and would be just find with even more reduced colors, and the hard edges are integral.

My safest recommendation for saving your gallery of Love Nikki images is to…

Create a subfolder

md jxl

Create another subfolder where you will store your PNG, that you will likely discard

md done

Now, run a loop over your current folder.

for %f in (*.png) do cjxl -e 9 -d .54 %f jxl/%~nf.jxl && move %f done

I think it’s important to move your discarded files into a “done” folder or whatever you like to call it. It makes it easy to keep track of what you already compressed. Dummies like me will likely want to recompress them all as a jpeg anyway, so I can post them in Discord or Cupeupload.

Save backups while you are compressing, since it is easy to delete or overwrite files in the console.

I will do this command on the example style I was showing, but remove the second command that makes the operated file move into a separate folder upon successful completion of the first command.

for %f in (Screenshot_20231220-114018.png) do cjxl -e 9 -d .54 %f jxl/%~nf.jxl

I waited about eight seconds for my Surface Pro to compress this image into the designated folder. The output is 137KB. Compare with the cjpeg_hdr compression, which was 147KB, with an inferior quality (distance 1 instead of distance .54). You aren’t looking at my files, but… you can try this on your own style!

It’s important to note that I used a Surface Pro because older computers struggle with the encoder. It’s also important to note that this was a pretty plain screenshot, since it doesn’t have a background. More detailed screenshots with lots of accessories and a background image will be much bigger. Also!! I have this setting set to .54 distance, which is the different from the default distance of 1. .54 distance is about 95 quality. 1 distance is about 90 quality.

On the topic of quality as distance parameters are equivalent to quality parameters, you can do the same thing in ImageMagick. I’ll redo the command for ImageMagick

for %f in (Screenshot_20231220-114018.png) do magick %f -quality 95 jxl/%~nf_im.jxl

I changed the filename so I can show you they are about the same! If the filename was the same, then it would overwrite, but you see I want to compare cjxl with imagemagick

aboutthesame

You see, they are about the same! ImageMagick took much longer to write the file. I prefer cjxl’s performance. The cjxl version actually looks better to me, when I compare side by side. So take it from me, the official encoder rocks!

Other things to note about JXL: Waterfox supports it, so if you want to build webpages, I can recommend you use the fork of Firefox known as Waterfox (the security updates are behind Firefox, so everyone on the Internat advocates against using it instead of Firefox). Image readers that can use JXL are IrfanView, XnView MP, and Nomacs. There is always more than that, but that should be useful to you. Also, IrfanView requires that you install plugins from the official website even after you install. It’s mentally tasking, I concede.

Overall, you can see why I prefer JXL for all my screenshots. I save so much space, even at high quality. These are screenshots that I will look back on with love. They will not occupy a lot of disk space and make me miserable. I know all those beautiful moments have been captured in the finest way possible. The default distance 1 setting (known as visually lossless) is really the recommended, but if you think your screenshots are beautiful, saving the good ones as distance .54 will leave you with fewer regrets!

Screenshot_20231220-114018_jxl

What 154KB JXL, with distance .54, looks like displayed as a PNG!

Commands for other formats (like AVIF, JPEG, WebP, DJVU)

I also mentioned formats PNG (palette), JPEG, AVIF, WEBP (lossless), WEBP (lossy), and DJVU.

I feel like that rant will get so heavy our heads will hurt. It’s a lot to explain how and where to install every tool. So like I have been assuming, I will assume you already installed these tools. They are awesome tools for manipulating your images!! In order they are pngnq.exe, cjpeg_hdr.exe, magick.exe, and c44.exe.

for a PNG palette

for %f in (Screenshot_20231220-114018.png) do pngnq %f -d pal -e .png

for a JPEG

for %f in (Screenshot_20231220-114018.png) do cjpeg_hdr %f jpeg/%~nf.jpg .54

for a WebP (lossless)

for %f in (Screenshot_20231220-114018.png) do magick %f -define webp:lossless=true webp_lossless/%~nf.webp

for a WebP (lossy)

for %f in (Screenshot_20231220-114018.png) do magick %f -quality 60 webp_lossy/%~nf.webp

for an AVIF

for %f in (Screenshot_20231220-114018.png) do magick %f avif/%~nf.avif

for a DJVU

magick mogrify -format ppm Screenshot_20231220-114018.png
for %f in (Screenshot_20231220-114018.ppm) do c44 -slice 73+13+10+10 %f djvu/%~nf.djvu

I think it would be good to compare the file sizes I got for each of these potential formats that you would be trying.

JXL: 154KB

JPEG: 202KB

PNG (palette): 228KB

Webp (lossless): 389KB

Webp (lossy): 38KB

AVIF: 22KB

DJVU: 75KB

I learned this year that smaller does not necessarily equal better. After trying different formats, I realized nothing could defeat JXL. However, DJVU does an amazing job looking good, being fast to load, and compressing size. So you can see why it has taken my breath away. It works good for drawings and it works good for Love Nikki screenshots. I have found another one-size-fits-all, I suppose. JXL is more faithful for smaller size, so I do think it is the precious ideal, whereas DJVU is just another lossy option to choose from. It is like lossy WebP, lossy AVIF (which, YES, does have a complementing lossless function but no one talks about it cos JXL does it better), lossy JXL (like I just admitted, JXL has the superior lossless compression but JXL doesn’t brag about it that much…maybe because it is slow), and JPEG. Nobody on God’s green earth uses palette PNG these days, but Love Nikki devs found a use for it, and frankly this is the year I fell in love with palette PNG, too.

So you can keep trying different options for saving your images in a lossy way and I do think it is fun. I think PNG palette and DJVU are the hardest to figure out. JXL and JPEG just need the binaries from libjxl installed, and webp (lossless), WebP (lossy) and AVIF require ImageMagick to create create them as I did. Also, WebP and AVIF have reference libraries too with binaries for Windows, you know, but I only use them for animations. I’ve needed to use libwebp to demux an animated webp, yes it makes no sense, and I’ve needed to use libavif to pipe an ffmpeg animation into the encoder. I keep losing that goddamn command, so I’ll post it here!

ffmpeg -i animation%2d.png -pix_fmt yuv444p -f yuv4mpegpipe - | avifenc --stdin final.avif

Also, WebP (lossless) is a great solution when you have a palette PNG and you want to deliver it on the web. Like, for instance, Discord. The lossless from WebP will be superior to the lossless from PNG. But it is a multi-step process. Just like how you saw I had to convert a PNG into a Portable PixMap (PPM) in order to make a DJVU, you would be converting the PNG into a palette PNG and then resaving it as a lossless WebP. It takes longer for sure! But it’s creative.

….

I’m really excited about DJVU and JXL. I think those formats are just the nicest for the artist. I would like to see more artists messing with the format and more importantly, benefitting from them. It seems silly to ask everyone to switch to DJVU, but if you can get supporting software, and enjoy that supporting software, you’re gonna have a great time! I need to write expositions/explanations on the situations of JXL and DJVU, as they are pitiful situations, and yet they are amazing formats.

38p59a3