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

Split the transcoder module in 4 modules: api, svg, svg2svg and tosvg #116

Merged
merged 1 commit into from
Dec 24, 2024

Conversation

carlosame
Copy link
Member

Sometimes an SVG library is embedded into an executable, and a common concern for both EchoSVG and Batik users in those cases is to make the size of the embedded modules as small as possible.

Notably, in the case of the Transcoder a number of unneeded classes may be included. For an example of such concern see

eclipse-platform/eclipse.platform.swt#1438 (comment)

The current transcoder module was designed as a monolithic do-it-all package, with users always carrying code that they do not intend to run. But it can be split in several submodules, in a way that backwards compatibility is kept (the old transcoder module still exists and provides all the classes), so users willing to minimize their dependencies can choose a smaller specific sub-module.

This PR splits the transcoder in 4 modules:

  • transcoder-api (API)
  • transcoder-svg (SVG to image)
  • transcoder-svg2svg (SVG to SVG)
  • transcoder-tosvg (conversions to SVG, currently only WMF to SVG)

In the typical case of rendering SVG as a PNG, the current 2.0 transcoder with dependencies fills a jar of 6.26 MB, while the specific SVG-to-image transcoder becomes a bit smaller (5.98 MB).

The gains are higher for the WMF to SVG case (3.94 MB) or the SVG-to-SVG (3.60 MB). Note that there is plenty of room for improvement in conversions to SVG, because the current code uses the SVG DOM implementation provided by the anim module (with all its dependencies) but the JDK DOM implementation could be used instead (like in the EchoSVG Wiki example for SVGGraphics2D).

Sometimes an SVG library is embedded into an executable, and a common concern
for both EchoSVG and Batik users in those cases is to make the size of the
embedded modules as small as possible.

Notably, in the case of the Transcoder a number of unneeded classes may be
included. For an example of such concern see

eclipse-platform/eclipse.platform.swt#1438 (comment)

The current `transcoder` module was designed as a monolithic do-it-all package,
with users always carrying code that they do not intend to run. But it can be
split in several submodules, in a way that backwards compatibility is kept (the
old `transcoder` module still exists and provides all the classes), so users
willing to minimize their dependencies can choose a smaller specific sub-module.

This commit splits the transcoder in 4 modules:

- `transcoder-api` (API)
- `transcoder-svg` (SVG to image)
- `transcoder-svg2svg` (SVG to SVG)
- `transcoder-tosvg` (conversions to SVG, currently only WMF to SVG)

In the typical case of rendering SVG as a PNG, the current 2.0 transcoder with
dependencies fills a jar of 6.26 MB, while the specific SVG-to-image transcoder
becomes a bit smaller (5.98 MB).

The gains are higher for the WMF to SVG case (3.94 MB) or the SVG-to-SVG (3.60
MB). Note that there is plenty of room for improvement in conversions to SVG,
because the current code uses the SVG DOM implementation provided by the `anim`
module (with all its dependencies) but the JDK DOM implementation could be used
instead (like in the EchoSVG Wiki example for `SVGGraphics2D`).
@carlosame carlosame added the enhancement New feature or request label Dec 19, 2024
@carlosame carlosame added this to the 2.0 milestone Dec 19, 2024
@carlosame carlosame merged commit f6ae721 into master Dec 24, 2024
5 checks passed
@carlosame carlosame deleted the fe-transcoder-split branch December 24, 2024 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant