-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to remove all unnecessary data #66
Comments
I assume your pngs contain transparency and no animation frames, therefore I use what we do here basically only preserve the pixel data(+ transparency) and discard everything else. And then nimPNG will try to find the best compression for your new png. let lres = loadPNG32(seq[uint8], "input.png")
if lres.isOk:
let png = lres.get()
let sres = savePNG32("output.png", png.data, png.width, png.height)
if sres.isErr:
echo sres.error
else:
echo lres.error |
then try this. it will take longer time, but produce smaller output. var conf = makePNGEncoder()
conf.filterStrategy = LFS_BRUTE_FORCE
let sres = savePNG32("output.png", png.data, png.width, png.height, conf) |
I think it's not related to compression. |
I see, then you can try to turn off var conf = makePNGEncoder()
conf.autoConvert = false |
alternative, read important chunk only, and then write back without reencoding. import ../nimPNG, streams
proc main() =
var conf = makePNGDecoder()
conf.colorConvert = false
conf.readTextChunks = false
conf.rememberUnknownChunks = false
var s = newFileStream("input.png", fmRead)
var png = decodePNG(seq[uint8], s, conf)
s.close()
s = newFileStream("output.png", fmWrite)
png.writeChunks s
s.close()
main() |
The first code produces 111B (better), gimp produces 103B. |
sorry, out of idea. |
Hi, I want to remove all unnecessary data from a png image, I usualy open the image in gimp and export with all options disabled.
But now I need to do this for ~200 images, so I wanted to automate this, and I thought about this package.
How can I get the equivalent of gimp's exported png ?
Thank you 🙂
The text was updated successfully, but these errors were encountered: