Skip to content
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

More efficient frame copying. #4

Merged
merged 4 commits into from Jul 22, 2021

Conversation

JimBobSquarePants
Copy link
Contributor

Just saw your tweet asking me for assistance with the ImageSharp API. This is my first time writing F# so I'm hoping I got it right!

I replaced the [x, y] frame iteration with a more efficient cloning. I also fixed the leak for the initial gif.

I did spot something else but I'm not confident in my F# to do a fix.

I wouldn't return a byte array from the getFrameFromGif method, I'd return the stream and copy it to a filestream in order to remove the overhead of allocating and copying a new array for each time.

@@ -28,7 +28,7 @@ Copyright (C) 2021 FreezeFrame

## Licenses For ImageSharp

- This tool uses [ImageSharp](https://sixlabors.com/products/imagesharp/), which requires a license for commercial use.
- This tool uses [ImageSharp](https://sixlabors.com/products/imagesharp/), which requires a license for commercial support.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

People can use the libraries commercially under the Apache license. They just can't ask me for any support unless they purchase a Six Labors license.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must be a line endings thing

Program.fs Outdated
image.[x,y] <- source.[x,y]
use gif = Image.Load(path)
use image = new Image<Rgba32>(gif.Width, gif.Height)
image.Frames.AddFrame(gif.Frames.RootFrame)|> ignore;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

; is optional in F# in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took me two reads to figure out what you meant there! 🤣

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops :-)

@baronfel
Copy link
Contributor

@JimBobSquarePants left an MR here showing how stream copying would be done, per your comment.

@khalidabuhakmeh khalidabuhakmeh merged commit c6d2c21 into khalidabuhakmeh:main Jul 22, 2021
@khalidabuhakmeh
Copy link
Owner

This is awesome. Thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants