tayloraswift / swift-png

decode, inspect, edit, and encode png images in pure swift

Home Page:https://swiftinit.org/docs/swift-png

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

latest tag is outdated

JaapWijnen opened this issue · comments

I'm seeing lots of changes since the latest tag, any plans for releasing a new tag? Any reason for not cutting a release yet? :) I noticed due to the example code not working for my version, which was the latest tag.

Also is there a built in way to resize images? If there is I can't find it for some reason

The recent changes are for version 4.0, which is coming very soon, as soon as I finish documenting the 4.0 API. (the WIP generated docs are here.) Which examples are you referring to? Version 3.0.2 and 4.0 have completely different slates of example programs.

Also, there is no built-in way to resize images. That's more of an image processing task that would belong in a separate library, since you would want to use the same features whether the source image came from a PNG or a JPEG.

Ah yes I was trying 4.0 examples with the 3.0 api 😅
About the resizing, hmm good point. Do you think a swift implementation could potentially be fast?
Currently using SwiftGD which wraps the gd library, but there a few memory leaks here and there and it stretches the image if you scale an image by an integer amount that's not a power of 2 for some reason. So I'm looking for alternatives :)
It would just be simple nearest neighbor scaling for now (although bilinear wouldn't be much harder I think), just not sure if this will be very slow compared to other solutions.

I’m not familiar with SwiftGD but the upscaling case sounds like something simple enough that you could implement from scratch in ~50-100 lines of Swift. All you would really have to do is loop over your 2D destination coordinates, and use rational integer arithmetic to find the corresponding pixel in the source image. The downscaling case would probably involve accumulating multiple pixels per destination pixel.

Version tag v4.0.0 has just been released, closing this issue