Jump to content

Can anyone provide an example how to use skia in emby?


mickle026

Recommended Posts

mickle026

I have absolutely no idea how to use skia sharp, let alone how to use it in emby.

I would like an example if anyone is willing??  on how to use it (impliment it) and then use it to take sections of images

I already know I need to create a canvas and draw on it, but I simply dont have a clue how.

I can do it in ffmpeg, so I can still do this within the emby environment but I would like to learn how to do it with skia sharp

This is what I mean, this will take an image and cut it in half

50% left 50% right, creating two seperate images.

Paid-In-Full-DVD-US.jpg.0458ceb371acea21ced99eb1a88bea94.jpg

ffmpeg.exe -i image.jpg -filter_complex "[0]crop=iw/2:ih:0:0[left];[0]crop=iw/2:ih:ow:0[right]" -map "[left]" left.jpg -map "[right]" right.jpg

left.jpg.9dfdeee9c821efafa6d425e168ae0bae.jpg     right.jpg.b6cf22d9964c562fcc37597a91f59c17.jpg

Help would be appreciated !

Link to comment
Share on other sites

I guess start with including SkiaSharp in your project if you haven't:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
   <TargetFrameworks>netstandard2.0</TargetFrameworks>
    <AssemblyVersion>{whatever version}</AssemblyVersion>
    <FileVersion>{whatever version}</FileVersion>
    <OutputType>Library</OutputType>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="mediabrowser.server.core" Version="{whatever version}" />
    <PackageReference Include="System.Memory" Version="{whatever version}" />
    <!-- You'll need to provide an ImageMagickSharp implementation of your code too if you want to support all Emby platforms -->
    <PackageReference Include="ImageMagickSharp" Version="{whatever version}" />
    <PackageReference Include="SkiaSharp" Version="2.88.3" />
  </ItemGroup>

  ...

</Project>

 

Link to comment
Share on other sites

mickle026
33 minutes ago, roaku said:

I guess start with including SkiaSharp in your project if you haven't:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
   <TargetFrameworks>netstandard2.0</TargetFrameworks>
    <AssemblyVersion>{whatever version}</AssemblyVersion>
    <FileVersion>{whatever version}</FileVersion>
    <OutputType>Library</OutputType>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="mediabrowser.server.core" Version="{whatever version}" />
    <PackageReference Include="System.Memory" Version="{whatever version}" />
    <!-- You'll need to provide an ImageMagickSharp implementation of your code too if you want to support all Emby platforms -->
    <PackageReference Include="ImageMagickSharp" Version="{whatever version}" />
    <PackageReference Include="SkiaSharp" Version="2.88.3" />
  </ItemGroup>

  ...

</Project>

 

Thanks, thats a given ......

I can do everything I want to do with ffmpeg - either by caching files or with a stream pipe server - so direct transfer into the plugin, but i'd really like to do this internally with the provided image libraries instead of waiting for an outside process to complete.

I know its strange that i can do something advanced like that with ffmpeg already and not know how to impliment skia or imagemagik, but thats how it is .... I only learned what I needed to at the time i needed to, im not an advanced programmer but a novice with some very good skills in some areas, but lacking drastically in others 🤔

 

Link to comment
Share on other sites

@mickle026

Are you wanting to modify the original images in a task or UI...or use Emby's image api to generate the edited images as they're requested by a client?

Link to comment
Share on other sites

mickle026

This question is mainly about the UI.

I'm wanting to modify mainly poster images when I fetch them from an external source.

 

Such as pulling full  covers ( both sides) and cropping out the front posters,

Or pulling people images and cropping them to portraits.

Some images I want to crop/stretch to a wide-screen and also make thumbnails.

Like I said I can do all this with ffmpeg already, but using skia and Imagemagik would be a better way to do it .

Edited by mickle026
Link to comment
Share on other sites

14 minutes ago, mickle026 said:

This question is mainly about the UI.

I'm wanting to modify mainly poster images when I fetch them from an external source.

 

Such as pulling full  covers ( both sides) and cropping out the front posters,

Or pulling people images and cropping them to portraits.

Some images I want to crop/stretch to a wide-screen and also make thumbnails.

Like I said I can do all this with ffmpeg already, but using skia and Imagemagik would be a better way to do it .

This would be a good place for you to start I think:

https://github.com/MediaBrowser/Emby/blob/master/Emby.Drawing.Skia/StripCollageBuilder.cs

It has everything from loading images from a path, a bunch of different modifications, and saving the final image.

You can use the SkiaSharp docs to reference as you go along:

https://learn.microsoft.com/en-us/dotnet/api/skiasharp.skbitmap.resize?view=skiasharp-2.88

 

In terms of the UI, I imagine you'd have to set up your own API endpoints to carry out actions based on actions taken in the UI. That's just general plugin stuff.

Edited by roaku
  • Thanks 1
Link to comment
Share on other sites

mickle026
1 hour ago, roaku said:

This would be a good place for you to start I think:

https://github.com/MediaBrowser/Emby/blob/master/Emby.Drawing.Skia/StripCollageBuilder.cs

It has everything from loading images from a path, a bunch of different modifications, and saving the final image.

You can use the SkiaSharp docs to reference as you go along:

https://learn.microsoft.com/en-us/dotnet/api/skiasharp.skbitmap.resize?view=skiasharp-2.88

 

In terms of the UI, I imagine you'd have to set up your own API endpoints to carry out actions based on actions taken in the UI. That's just general plugin stuff.

At work right now, but thanks for pointing me in the right direction I'll take a look and repost if I need more help.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...