You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sources/SnapshotTesting/Documentation.docc/Articles/ImageSerializationPlugin.md
+41-2
Original file line number
Diff line number
Diff line change
@@ -47,7 +47,46 @@ The **Image Serialization Plugin** relies on the PluginAPI that is a combination
47
47
- When an image needs to be serialized, the `ImageSerializer` checks the available plugins for one that supports the requested format.
48
48
- If no plugin is found, it defaults to the built-in PNG encoding/decoding methods.
49
49
50
-
#### Extensibility:
50
+
#### Extensibility
51
51
52
-
The plugin architecture allows developers to introduce new image formats without modifying the core SnapshotTesting library. By creating a new plugin that conforms to `ImageSerialization` and `SnapshotTestingPlugin`, other formats.
52
+
The plugin architecture allows developers to introduce new image formats without modifying the core SnapshotTesting library. By creating a new plugin that conforms to `ImageSerializationPlugin`, you can easily add support for additional image formats.
53
53
54
+
Here are a few example plugins demonstrating how to extend the library with new image formats:
55
+
56
+
-**[Image Serialization Plugin - HEIC](https://github.com/mackoj/swift-snapshot-testing-plugin-heic)**: Enables storing images in the `.heic` format, which reduces file sizes compared to PNG.
57
+
-**[Image Serialization Plugin - WEBP](https://github.com/mackoj/swift-snapshot-testing-plugin-webp)**: Allows storing images in the `.webp` format, which offers better compression than PNG.
58
+
-**[Image Serialization Plugin - JXL](https://github.com/mackoj/swift-snapshot-testing-plugin-jxl)**: Facilitates storing images in the `.jxl` format, which provides superior compression and quality compared to PNG.
59
+
60
+
## Usage
61
+
62
+
For example, if you want to use JPEG XL as a new image format for your snapshots, you can follow these steps. This approach applies to any image format as long as you have a plugin that conforms to `ImageSerializationPlugin`.
63
+
64
+
1.**Add the Dependency**: Include the appropriate image serialization plugin as a dependency in your `Package.swift` file. For JPEG XL, it would look like this:
This setup demonstrates how to integrate a specific image format plugin. Replace `JXLImageSerializer` with the appropriate plugin and format for other image formats.
0 commit comments