PNG quality with 30% size using JCC + a trick

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Post Reply
Message
Author
User avatar
jack_norton
Lemma-Class Veteran
Posts: 4087
Joined: Mon Jul 21, 2008 5:41 pm
Completed: Too many! See my homepage
Projects: A lot! See www.winterwolves.com
Tumblr: winterwolvesgames
Contact:

PNG quality with 30% size using JCC + a trick

#1 Post by jack_norton »

I post this here even if I'm not sure if is the right forum. Anyway been tallking with some indies on twitter having the problem of distribution size. When you start having 40+ characters sprites with 1024px of height like in Loren, becomes problematic.
The solution is simple, use JCC with a trick.
Some people complained that the resulting image of JCC is poor quality, blurred. Yes, personally is hard to notice and depends on the image, but the problem is that the library used (PIL) does a poor job. Even setting the MAX quality, the resulting image can be blurry in some areas/colors.
Solution? first use that and then manually export with photoshop (or another good art program) the image from PNG to JPG, overwriting the .base.jpg image resulted from the JCC split (the other image mask.jpg is the alpha channel info and doesn't need to be changed).
Result: 100% quality (if you save as max quality in photoshop the image will be IDENTIC) but 30-40% size depending on the image. Even the best PNG shrinker programs can reduce max of 20-25%, while here you get a reduction of 60%!
follow me on Image Image Image
computer games

AxemRed
Veteran
Posts: 482
Joined: Sun Jan 09, 2011 7:10 am
Contact:

Re: PNG quality with 30% size using JCC + a trick

#2 Post by AxemRed »

It's because Photoshop disables JPEG's chroma subsampling at high quality levels which is the cause of the blur.

User avatar
jack_norton
Lemma-Class Veteran
Posts: 4087
Joined: Mon Jul 21, 2008 5:41 pm
Completed: Too many! See my homepage
Projects: A lot! See www.winterwolves.com
Tumblr: winterwolvesgames
Contact:

Re: PNG quality with 30% size using JCC + a trick

#3 Post by jack_norton »

Hm I get the blur only if I use JCC that AFAIK uses the PIL libraries. When I save with photoshop the color part of the image, I get a perfect image, at least for my eyes (I'm not an artist though).
follow me on Image Image Image
computer games

AxemRed
Veteran
Posts: 482
Joined: Sun Jan 09, 2011 7:10 am
Contact:

Re: PNG quality with 30% size using JCC + a trick

#4 Post by AxemRed »

And AFAIK PIL uses libjpeg, the reference implementation for the file format. If you want to compare encoding efficiency, you'd need to compare quality at the same file size, preferably with the same subsampling settings.

Graph
Veteran
Posts: 230
Joined: Sat Jul 03, 2010 7:22 pm
Completed: Touhou Mecha Chap. 1
Projects: Touhou Mecha, Eastern Starlight Romance
Organization: Dai-Sukima Dan
Contact:

Re: PNG quality with 30% size using JCC + a trick

#5 Post by Graph »

So I decided to try out max quality JPEG over what the jcc.py gives me, after reading this. But I have two problems with PhotoShop's batch process:

1. Renaming files doesn't seem very flexible (couldn't tack .base.jpg on the end of every file)

2. If you tell it to "include all subfolders" in the conversion, it doesn't maintain the folder structure for the converted files and instead dumps everything in one folder, so I have to sort everything out again.

Do you guys use another program to streamline PNG to JPG conversion, or am I missing something?

LVUER
King of Lolies
Posts: 4538
Joined: Mon Nov 26, 2007 9:57 pm
Completed: R.S.P
Location: Bandung, West Java, Indonesia
Contact:

Re: PNG quality with 30% size using JCC + a trick

#6 Post by LVUER »

Do you know where I can get this JCC? I've been searching in all kind of websites and google but never find the correct JCC.
"Double the princesses, quadruple the fun!" - Haken Browning (SRW-OG Endless Frontier)

DeviantArt Account
MoeToMecha Blog (under construction)
Lolicondria Blog (under construction) <- NSFW

Graph
Veteran
Posts: 230
Joined: Sat Jul 03, 2010 7:22 pm
Completed: Touhou Mecha Chap. 1
Projects: Touhou Mecha, Eastern Starlight Romance
Organization: Dai-Sukima Dan
Contact:

Re: PNG quality with 30% size using JCC + a trick

#7 Post by Graph »

LVUER wrote:Do you know where I can get this JCC? I've been searching in all kind of websites and google but never find the correct JCC.
It's in the wiki-based Ren'py cookbook. I assume that means it was made by someone from around here, which is probably why you had trouble finding it.

http://www.renpy.org/wiki/renpy/doc/cookbook/JCC

User avatar
nyaatrap
Crawling Chaos
Posts: 1824
Joined: Mon Feb 13, 2012 5:37 am
Location: Kimashi Tower, Japan
Contact:

Re: PNG quality with 30% size using JCC + a trick

#8 Post by nyaatrap »

Xnview is easier and faster, and also can remove metadata.

AxemRed
Veteran
Posts: 482
Joined: Sun Jan 09, 2011 7:10 am
Contact:

Re: PNG quality with 30% size using JCC + a trick

#9 Post by AxemRed »

Graph wrote:Do you guys use another program to streamline PNG to JPG conversion, or am I missing something?
XnView is an option, but setting the JCC script's quality to 95-98% should already be close to optimal.

Graph
Veteran
Posts: 230
Joined: Sat Jul 03, 2010 7:22 pm
Completed: Touhou Mecha Chap. 1
Projects: Touhou Mecha, Eastern Starlight Romance
Organization: Dai-Sukima Dan
Contact:

Re: PNG quality with 30% size using JCC + a trick

#10 Post by Graph »

AxemRed wrote:
Graph wrote:Do you guys use another program to streamline PNG to JPG conversion, or am I missing something?
XnView is an option, but setting the JCC script's quality to 95-98% should already be close to optimal.
Ah, I should've thought of changing the script itself. It was easy to find the quality variable since you mentioned what I should be looking for. Thanks!

User avatar
TheGuraGuraMan
Veteran
Posts: 365
Joined: Sat Nov 03, 2012 3:48 pm
Location: France
Contact:

Re: PNG quality with 30% size using JCC + a trick

#11 Post by TheGuraGuraMan »

Recently found that : http://tinypng.org/ wonder if it would works...

AxemRed
Veteran
Posts: 482
Joined: Sun Jan 09, 2011 7:10 am
Contact:

Re: PNG quality with 30% size using JCC + a trick

#12 Post by AxemRed »

It's basically pngquant/pngnq wrapped in a webservice. It decreases the PNG to 256-color mode, with a noticeable quality loss especially for larger images.

Post Reply

Who is online

Users browsing this forum: No registered users