-
Notifications
You must be signed in to change notification settings - Fork 579
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
Add Image Serialization Plugin #906
Open
mackoj
wants to merge
8
commits into
pointfreeco:main
Choose a base branch
from
mackoj:faet/ImageSerializationPlugin
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mackoj
force-pushed
the
faet/ImageSerializationPlugin
branch
from
September 16, 2024 09:40
21e1a8d
to
87ebba0
Compare
mackoj
force-pushed
the
faet/ImageSerializationPlugin
branch
4 times, most recently
from
September 16, 2024 21:08
4e6843c
to
ddac472
Compare
I hope this better explains what I’m trying to achieve with this PR. The FilePlugin doesn’t exist yet, but it’s a potential future plugin (prototype implementation not finished). graph TD
Dev --> A(Strategies)
Dev -. "Third-Party" .-> B(Strategies)
Dev --> C(Strategies)
Dev -. "Third-Party" .-> D(Strategies)
A --> swift-snapshot-testing
B --> swift-snapshot-testing
C --> swift-snapshot-testing
D --> swift-snapshot-testing
subgraph swift-snapshot-testing
Plugin
Plugin --> Image
Plugin --> File
end
Image -- "Default Value" --> PNG
Image -. "Third-Party" .-> JXL
Image -. "Third-Party" .-> HEIC
File -- "Default Value" --> Local
File -. "Third-Party" .-> SFTP
File -. "Third-Party" .-> S3
%% Style adjustments to highlight default values
style PNG stroke:#FF0000,stroke-width:3px
style Local stroke:#FF0000,stroke-width:3px
%% Style adjustments for optional nodes
classDef optionalNode stroke-dasharray: 5,stroke:#333,fill:#E0E0E0,color:#000000
linkStyle default stroke:#005f73
classDef teal fill:#006d77,stroke:#333,color:#FFFFFF
classDef lightTeal fill:#83c5be,stroke:#333,color:#000000
classDef blue fill:#028090,stroke:#333,color:#FFFFFF
classDef purple fill:#6a4c93,stroke:#333,color:#FFFFFF
classDef lightBlue fill:#b2f7ef,stroke:#333,color:#000000
classDef orange fill:#ff6700,stroke:#333,color:#000000
Dev:::teal
A:::lightTeal
B:::optionalNode
C:::lightTeal
D:::optionalNode
swift-snapshot-testing:::blue
Plugin:::purple
Image:::purple
File:::purple
PNG:::purple
JXL:::optionalNode
HEIC:::optionalNode
Local:::purple
S3:::optionalNode
SFTP:::optionalNode
|
adozenlines
approved these changes
Sep 28, 2024
What has changed regarding the public API of swift-snapshot-testing. Inside
The new
The new
That's it. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR need to be merged after #905 that lays the groundwork for the usage of plugin inside
swift-snapshot-testing
.Overview
This PR introduces a plugin for image serialization that all existing strategies will be using by default, enhancing the flexibility and extensibility of image handling within the framework. This plugin allows for the integration of various image formats through plugins, which can be dynamically discovered and registered at runtime. The core components of this implementation include the
ImageSerializationPlugin
protocol and theImageSerializer
class, designed to manage and utilize these plugins.Key Features
ImageSerializationPlugin Protocol: Defines methods for encoding and decoding images, allowing conforming classes to support various image formats. It combines the functionalities of
ImageSerialization
andSnapshotTestingPlugin
for seamless integration with the existing plugin system.imageFormat
: A static property that specifies the format supported by the plugin.encodeImage(_:)
: Encodes an image into the specified format.decodeImage(_:)
: Decodes image data back into an image.ImageSerializer Class: Manages the encoding and decoding of images using available plugins. It:
PluginRegistry
.Dynamic Plugin Discovery: Plugins conforming to the
ImageSerializationPlugin
protocol are automatically discovered and registered using the Objective-C runtime, making it easy to extend supported formats without modifying core functionality.Benefits
This PR lays the groundwork for a more modular and flexible approach to image serialization within SnapshotTesting, setting the stage for future enhancements and customizations through dedicated plugins.
Examples of plugins that use the
ImageSerializationPlugin
Warning
These implementations are tests and prototypes, not production-ready. They are simply here to demonstrate how easy it is to use the
ImageSerializationPlugin
..heic
format, which reduces file sizes compared to PNG..webp
format, which offers better compression than PNG..jxl
format, which provides superior compression and quality compared to PNG.