Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Using SaveImage() can massively reduce the file size!!!

Author
Message
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 17th Feb 2016 11:01
I was just doing a simple test and discovered a rather bizarre but very welcome 'feature'.
SaveImage() can (in some cases) massively reduce the size of the PNG file. It isn't always the case - sometimes it is slightly bigger but I noticed that in many case the file size was more than halved!

Images that other people have created don't seem to benefit as much as ones that I create myself, so maybe it is Photoshop that is creating large files but it's still worth trying this on your images if you want to reduce the file size:



As an experiment, I tried several methods of saving a PNG from Photoshop.
No compression - 281,937 bytes
Compression, no interlace - 33,419 bytes
Compression, interlaced - 37,479 bytes
SaveImage() from AppGameKit - 15,381 bytes !!!!
AGK V2 user - Tier 1 (mostly)
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 17th Feb 2016 12:13
Try saving the PNG as 8 or 16 bit in Photoshop. Unless you need 32 bit? PS do add extra info to the file and there are programs available that can remove the extra info.
JohnnyMeek
11
Years of Service
User Offline
Joined: 23rd Apr 2013
Location: Slovenia
Posted: 17th Feb 2016 12:24
Or try this...

https://tinypng.com/

Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 17th Feb 2016 12:38
Good tip!
TinyPNG is amazing! I tried the same file that gave the results above and tinyPNG got it down to 6k with no noticeable difference
AGK V2 user - Tier 1 (mostly)
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 17th Feb 2016 13:37
Quote: "Or try this...

https://tinypng.com/"


Nice, added to my bookmarks!
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 17th Feb 2016 14:50 Edited at: 17th Feb 2016 14:52
Quote: "Advanced lossy compression"

if you have the original image its no problem.
normal the png is without loss at save, that was the advantage in compare with jpg.
AGK (Steam) V2.0.16 : Windows 10 Pro 64 Bit : AMD (15.30.1025) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 18th Feb 2016 20:47
Quote: "24-bit PNG files can be converted to much smaller 8-bit indexed color images"


One would safely assume there would possibly be significant quality lost.

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 19th Feb 2016 09:14 Edited at: 19th Feb 2016 09:15
Hopefully it is configurable, but this looks pretty damn good to me...

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
JohnnyMeek
11
Years of Service
User Offline
Joined: 23rd Apr 2013
Location: Slovenia
Posted: 19th Feb 2016 09:31
There are a few of these online, plus there's a free plugin for photoshop.

http://www.fnordware.com/superpng/
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 19th Feb 2016 09:38 Edited at: 19th Feb 2016 10:55
The only issue I have come up with so far when using tinyPNG (and it is a TINY issue) is that monochrome images don't stay monochrome.
They are very close and not visible noticeable but not quite spot on.

The only reason I noticed is because I've created an image compression and encryption algorithm and it scans the image first to see if it has colour pixels or just a single colour image (think bitmap fonts) if it is just a single colour image then it can use a more efficient algorithm that discards all colour information and just processes the alpha channel.

If I use tinyPNG on a file first and then run it through my compression/encryption function it always selects the full colour option.

Like I said, it is a tiny issue and one that won't affect many users but it's worthy of pointing out.
AGK V2 user - Tier 1 (mostly)
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 19th Feb 2016 15:26
Regarding how many bits you should use for PNGs. 8 bit is fine as long as you don't need a better alpha channel and your image doesn't contain too may colors or gradients. You only get 256 colors or 255 + transparent pixels. 24 bit with transparency is usually the better option if you want smooth edges, because you get much better alpha information. 32 bit and 24 bit without transparency is however completely lossless.

Login to post a reply

Server time is: 2024-09-29 11:26:02
Your offset time is: 2024-09-29 11:26:02