OnlyM icon indicating copy to clipboard operation
OnlyM copied to clipboard

Enable support for SVG images

Open jstevensen opened this issue 3 years ago • 5 comments

Is your feature request related to a problem? Please describe. Some newer publications have SVG images instead of JPG, such as the Teaching Box in the current CBS book. For now, I'm converting these to png using Imagemagick.

Describe the solution you'd like OnlyM would be able to display an SVG image.

Describe alternatives you've considered Converting the image to a supported format, such as JPG or PNG.

Additional context

jstevensen avatar Jun 08 '21 17:06 jstevensen

Support for SVG images would make it easier for Media to import images for newer publications without having to convert the images

timjobutler avatar Aug 11 '21 08:08 timjobutler

@AntonyCorbett I would like to take on this issue. Any information you can provide on how to build this project locally, run tests etc. would be helpful. Thank you!

Notabela avatar Jan 02 '22 04:01 Notabela

@Notabela Thanks for your kind offer - please go ahead. The solution is currently built in VS 2019 and there are a small number of integration tests in the IntegrationTests project. Please feel free to add tests if needed. Regarding SVG support, one option may be to create a Converter so that the image can be displayed in the existing Image component.

If you make changes to the string resources (resources.resx, etc) please don't include in your PR any non-native resource files. These are generated by the Crowdin localisation tool.

Thanks again. Please let me know if you have any questions.

AntonyCorbett avatar Jan 02 '22 08:01 AntonyCorbett

Thanks @AntonyCorbett Do you mind pointing me to the file or set of files to start from to begin to understand how images are processed in OnlyM. That might speed this up a bit for me. Thanks in advance!

Notabela avatar Jan 04 '22 02:01 Notabela

@Notabela Please see below:

OnlyM.Core MediaProviderService should be updated to include the SVG image type.

OnlyM ImageDisplayManager contains the code that renders images in the Image control. This is the standard WPF Image control (which doesn't support SVG files), so I would approach this by modifying the OnlyM.CoreSys GraphicUtils.InternalGetBitmapImage method so that it recognises SVG content and converts it to a XAML-compatible BitmapImage.

There are some resources online that may help with the SVG to XAML conversion, e.g. https://github.com/BerndK/SvgToXaml

AntonyCorbett avatar Jan 04 '22 10:01 AntonyCorbett

@Notabela I have implemented support for SVG in the latest pre-release. Sorry if this duplicates work you may have done.

AntonyCorbett avatar Aug 25 '23 17:08 AntonyCorbett

@jstevensen Implemented in the latest pre-release.

AntonyCorbett avatar Aug 25 '23 17:08 AntonyCorbett