fogleman / gg

Go Graphics - 2D rendering in Go with a simple API.
https://godoc.org/github.com/fogleman/gg
MIT License
4.37k stars 354 forks source link

Reducing the file size #111

Open sahilpaudel-pe opened 3 years ago

sahilpaudel-pe commented 3 years ago

dc.SavePNG("out.png")

Won't this degrade the quality of the image?

kirides commented 3 years ago

PNG is usually a lossless file format. It stores the image as zipped data.

Jpeg on the other hand is a lossy file format. And thus degrades image quality.

achims1 commented 2 years ago

I think png can actually be recompressed, because the pictures we draw are actually 32-bit, but we can convert them to 8-bit images such as websites like tinypng

kirides commented 2 years ago

Reducing the bits is a lossy operation if there are more than 8Bits of color.

Many Websites use slightly lossy compression algorithm by cleaning up some neighbouring pixels. Pngout for example features such things iirc.

achims1 commented 2 years ago

I have done some methods to compress the image without changing the size, but the time is too long, so do you know other third-party packages that can solve this problem?