Skip to content

[Lottie] Allow to choose export format #1309

Closed

Description

@morevnaproject

As of #1289 export to Lottie is called via "File" -> "Export" format.

Currently the Export dialog allows to select file type (just one option at the moment - "Lottie JSON"). But when export is done it creates two files - "json" and "html". It would be nice to have two filetype options - "Lottie JSON" and "Lottie HTML".

screenshot_003


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Activity

  1. mbasaglia commented on Mar 31, 2020

    @mbasaglia
    Contributor

    Link to my previous comment: #1289 (comment)

  2. morevnaproject commented on Mar 31, 2020

    @morevnaproject
    MemberAuthor

    In response to #1289 (comment):

    It could be implemented by having multiple exporters in a single plugin but I think allowing multiple plugins in the same directory (sharing the same codebase) is more future-proof.

    I think import/export plugins should be separated from other plugins, listed in "Plugins" menu. I feel they are completely different "beast". ^__^

  3. mbasaglia commented on Mar 31, 2020

    @mbasaglia
    Contributor

    I think import/export plugins should be separated from other plugins, listed in "Plugins" menu. I feel they are completely different "beast". ^__^

    Yeah after my export implementation they are stored in a separate list in the plugin manager.

    I was thinking about reworking the way plugins are handled, having a proper Plugin class instead of a struct with direct member access.
    Having accessor functions to plugin data could also allow translated strings to work better as they'd return the value based on the current locale (currently the plugin name is localized based when the plugin is loaded).

    This would open up the possibility of having different kinds of plugin, maybe even using different interpreters instead of just python?

  4. AnishGG commented on Mar 31, 2020

    @AnishGG
    Member

    But when export is done it creates two files - "json" and "html".

    Actually there is one more file .log, that is also created. It stores the necessary logs, for instance if some kind of failure occurs.

    This would open up the possibility of having different kinds of plugin, maybe even using different interpreters instead of just python?

    This would be amazing!

  5. mbasaglia commented on Mar 31, 2020

    @mbasaglia
    Contributor

    The need for logs could also be removed, maybe synfig can handle stdout/stderr from plugins a bit differently than what it currently does

  6. mbasaglia commented on Mar 31, 2020

    @mbasaglia
    Contributor

    Here's my proposal for improvements to the Plugin system:

    Import/Export plugin description

    <plugin>
        <!-- translatable, not strictly needed for exporters
            but if in the future there is going to be
            something like a dialog to enable/disable plugins
            or whatever it might be worth keeping -->
        <name>Plugin name</name>
    
        <!-- A plugin can define multiple exporters -->
        <exporter>
            <!-- An exporter can have multiple extensions -->
            <extension>.foo</extension>
            <extension>.bar</extension>
            <!-- Text shown in the Export dialog (translatable) -->
            <description>Example exporter (*.foo, *.bar)</description>
            <!-- worth having exec per exporter,
                in case a plugin wants to have different scripts for different formats -->
            <!-- stdout/stderr attributes define how the output is to be handled by synfig
                "ignore" does nothing, "message" shows App::dialog_message_1b,
                "log", calls synfig::info -->
            <!-- interpreter is the interpreted, "python" by default
                (and perhaps the only option for now) -->
            <exec stdout="log" stderr="message" interpreter="python">myscript.py</exec>
            <!-- extra options for the plugin -->
            <options>
                <!-- will pass `--foobar 123` to `myscript.py`
                `type` is for future extensibility, to build a dialog for some options
                as some format might require them.
                For now it could be used to have different exporters using the same script
                -->
                <option name="--foobar" value="123" type="hidden" />
            </options>
        </exporter>
    
        <importer><!-- same stuff as exporter --></importer>
    </plugin>

    The extra attributes for <exec> (all optional) and the idea of <options> to build
    a dialog with plugin options can also be used by non import/export plugins.

    Code changes

    • Support for importer plugins
    • Separate types for importers/exporters and other plugins
    • Generalize the code used to run the plugins, and move it in the plugin manager
    • Use an internal ID for the plugin instead of passing the path to the script when triggering plugins from the UI
    • Use Glib::spawn_sync to run commands instead of popen
    • Output stream management as described above

    It's all rather simple stuff, so if everything is ok I can start implementing it.

  7. rodolforg commented on Mar 31, 2020

    @rodolforg
    Contributor

    I like your proposal!
    My suggestions:

    1. I think it should accept multiple exporter and importer tags.
    2. The name and description tags should be accept translations in a similar way FreeDesktop Desktop rule for .desktop file:
    <name>Name</name>
    <name lang="pt_BR">Nome</name>
    <name lang="fr">Nom</name>
  8. mbasaglia commented on Mar 31, 2020

    @mbasaglia
    Contributor

    yeah those things are mentioned in the proposal.

  9. rodolforg commented on Mar 31, 2020

    @rodolforg
    Contributor

    Oh sorry! I didn't the comment about supporting multiple exporters lol.
    Regarding translations, I just proposed how it could be done.

  10. mbasaglia commented on Apr 1, 2020

    @mbasaglia
    Contributor

    I created a branch that implements most of the things listed in my proposal above.

    It doesn't yet contain import plugins and options.

  11. morevnaproject commented on Apr 1, 2020

    @morevnaproject
    MemberAuthor

    I think import/export plugins should be separated from other plugins, listed in "Plugins" menu. I feel they are completely different "beast". ^__^

    Yeah after my export implementation they are stored in a separate list in the plugin manager.

    I mean to store them in completely different location and assume they might have different XML structure. ^__^
    This way the format of regular plugins won't hold you from making changes to format of importer/exporter plugins.

    Being said that, I am not against of implementation in #1313. This is just my thoughts. ^__^


           ...
           <!-- An exporter can have multiple extensions -->
            <extension>.foo</extension>
            <extension>.bar</extension>
            <!-- Text shown in the Export dialog (translatable) -->
            <description>Example exporter (*.foo, *.bar)</description>
           ...
    

    Looks cool!
    I suggest to use <description>Example exporter</description> for description tag instead and have stuff from tags added automatically.

    In this case, it would be nice for two tags generate two separate entries for filetype combobox:

    • Example exporter (*.foo)
    • Example exporter (*.bar)

    instead of

    • Example exporter (*.foo, *.bar)

    This will be easier for user to choose particular format (with single extension) and Synfig can add extension to filename automatically.

    In latter case (I mean Example exporter (*.foo, *.bar)) there is uncertainty and user have type extension manually if he wants ".bar" instead of ".foo". ^__^


    Another suggestion is to completely remove <description> and use string from <name> tag. ^__^


    For <extension> tag I also suggest to remove dot at the start. ^__^

  12. mbasaglia commented on Apr 1, 2020

    @mbasaglia
    Contributor

    I see the different <extension> more as alternatives for the same format than separate formats (eg: .jpg .jpeg).

    I agree that the (*.foo, *.bar) stuff can be automated but I'm not sure how it's supposed to work with internationalization (specifically right-to left languages).

    I think it's worth having <description> in case a plugin exports different formats (eg: it might be a bit confusing to see "Lottie (.json)" "Lottie (.html)", I think it's probably better to allow having different descriptions, but maybe it can be optional?

    For example, my plugin adds support for Telegram stickers, SVG, and other formats (all sharing the same codebase) so I think they should have different names in the dialog.

  13. morevnaproject commented on Apr 2, 2020

    @morevnaproject
    MemberAuthor

    I agree that the (*.foo, *.bar) stuff can be automated but I'm not sure how it's supposed to work with internationalization (specifically right-to left languages).

    Ah, okay, you right.

    For example, my plugin adds support for Telegram stickers, SVG, and other formats (all sharing the same codebase) so I think they should have different names in the dialog.

    You right, in this case you can have multiple <exporter> sections with different descriptions.

    "Lottie (.json)", "Lottie (.html)"

    I think having separate entries "Lottie (.json)" and "Lottie (.html)" is perfectly fine. This actually was my intention to get it like that when I started this issue. ^__^

    Well, then we can just have 2 separate <exporter> entries for Lottie.

    Okay, everything is resolved then. ^__^

  14. mbasaglia commented on May 9, 2020

    @mbasaglia
    Contributor

    probably this can be closed now

  15. morevnaproject commented on May 9, 2020

    @morevnaproject
    MemberAuthor

    Yes, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions