question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature: "containing" images

See original GitHub issue

I’m working on a web app using lottie with some custom tweaks to enable users to replace some of the content, previewing in the browser and then render it in node.js.

We’ve been doing it for while and it works well with some tweaks, but would like to avoid having our own fork since it’s a pain to upgrade, and others might benefit from our changes.

Since our replacement images may be any format (aspect ratio) and size, and we don’t want them to be cropped, we changed it to work like the equivalent of object-fit: contain in css.

Is this something you would want in Lottie? Looking at the code, the current solution (cropping) looks quite deliberate, and since our usage case in not the normal/intended one I’d understand if not. We’re doing it for all images but perhaps it should be opt-in per image via assets and/or support other object-fit options.

If not, exposing a reference to CVImageElement somehow so we can override imageLoaded would also enable us override the positioning without changing the lottie code as well.

For svg and html I think this would be even easier with xMidYMid meet instead of xMidYMid slice in IImageElement.

Thanks for the great work on lottie!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
bodymovincommented, Jun 21, 2018

I’ve added on version 5.1.18 a property “imagePreserveAspectRatio” to the rendererSettings to support meet and slice. For now, on the canvas renderer, it only supports “xMidYMid meet” and “xMidYMid slice”. If people need the others I’ll consider adding them. the svg and html renderers support all of the existing preserveAspectRatio options. It also looks for a property “pr” on each image asset in the json file that has precedence over the general setting.

0reactions
fridaycommented, Sep 28, 2018

@knowBalpreet I always meant to do that, but didn’t make time for it. Just published it here https://github.com/friday/lottie-node. Make sure to read and follow the instructions since otherwise it will not work.

It’s not very well tested, but has been working for us (although this version had to be rewritten a bit in the process of extracting it from our code)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Feature (computer vision) - Wikipedia
In computer vision and image processing, a feature is a piece of information about the content of an image; typically about whether a...
Read more >
539889 Features Images, Stock Photos & Vectors - Shutterstock
Features royalty-free images. 539,889 features stock photos, vectors, and illustrations are available royalty-free. See features stock video clips.
Read more >
30k+ Feature Pictures | Download Free Images on Unsplash
Download the perfect feature pictures. Find over 100+ of the best free feature images. Free for commercial use ✓ No attribution required ✓...
Read more >
Classifying Images with Feature Transformations
Classifying Images with Feature Transformations. Exploring the MNIST1 and FASHION MNIST2 dataset with Logistic Regression and Random Forest.
Read more >
What is a Feature Descriptor in Image Processing? - Baeldung
A feature descriptor is the information retrieved from images in the form of numerical values that are challenging for a human to comprehend...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found