|  | @@ -205,11 +205,6 @@ namespace Jellyfin.Drawing.Skia
 | 
	
		
			
				|  |  |          /// <exception cref="SkiaCodecException">The file at the specified path could not be used to generate a codec.</exception>
 | 
	
		
			
				|  |  |          public ImageDimensions GetImageSize(string path)
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  | -            if (path == null)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                throw new ArgumentNullException(nameof(path));
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |              if (!File.Exists(path))
 | 
	
		
			
				|  |  |              {
 | 
	
		
			
				|  |  |                  throw new FileNotFoundException("File not found", path);
 | 
	
	
		
			
				|  | @@ -297,7 +292,7 @@ namespace Jellyfin.Drawing.Skia
 | 
	
		
			
				|  |  |          /// <param name="orientation">The orientation of the image.</param>
 | 
	
		
			
				|  |  |          /// <param name="origin">The detected origin of the image.</param>
 | 
	
		
			
				|  |  |          /// <returns>The resulting bitmap of the image.</returns>
 | 
	
		
			
				|  |  | -        internal SKBitmap Decode(string path, bool forceCleanBitmap, ImageOrientation? orientation, out SKEncodedOrigin origin)
 | 
	
		
			
				|  |  | +        internal SKBitmap? Decode(string path, bool forceCleanBitmap, ImageOrientation? orientation, out SKEncodedOrigin origin)
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  |              if (!File.Exists(path))
 | 
	
		
			
				|  |  |              {
 | 
	
	
		
			
				|  | @@ -348,12 +343,17 @@ namespace Jellyfin.Drawing.Skia
 | 
	
		
			
				|  |  |              return resultBitmap;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        private SKBitmap GetBitmap(string path, bool cropWhitespace, bool forceAnalyzeBitmap, ImageOrientation? orientation, out SKEncodedOrigin origin)
 | 
	
		
			
				|  |  | +        private SKBitmap? GetBitmap(string path, bool cropWhitespace, bool forceAnalyzeBitmap, ImageOrientation? orientation, out SKEncodedOrigin origin)
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  |              if (cropWhitespace)
 | 
	
		
			
				|  |  |              {
 | 
	
		
			
				|  |  |                  using (var bitmap = Decode(path, forceAnalyzeBitmap, orientation, out origin))
 | 
	
		
			
				|  |  |                  {
 | 
	
		
			
				|  |  | +                    if (bitmap == null)
 | 
	
		
			
				|  |  | +                    {
 | 
	
		
			
				|  |  | +                        return null;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |                      return CropWhiteSpace(bitmap);
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
	
		
			
				|  | @@ -361,13 +361,11 @@ namespace Jellyfin.Drawing.Skia
 | 
	
		
			
				|  |  |              return Decode(path, forceAnalyzeBitmap, orientation, out origin);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        private SKBitmap GetBitmap(string path, bool cropWhitespace, bool autoOrient, ImageOrientation? orientation)
 | 
	
		
			
				|  |  | +        private SKBitmap? GetBitmap(string path, bool cropWhitespace, bool autoOrient, ImageOrientation? orientation)
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  | -            SKEncodedOrigin origin;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |              if (autoOrient)
 | 
	
		
			
				|  |  |              {
 | 
	
		
			
				|  |  | -                var bitmap = GetBitmap(path, cropWhitespace, true, orientation, out origin);
 | 
	
		
			
				|  |  | +                var bitmap = GetBitmap(path, cropWhitespace, true, orientation, out var origin);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  if (bitmap != null && origin != SKEncodedOrigin.TopLeft)
 | 
	
		
			
				|  |  |                  {
 | 
	
	
		
			
				|  | @@ -380,7 +378,7 @@ namespace Jellyfin.Drawing.Skia
 | 
	
		
			
				|  |  |                  return bitmap;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            return GetBitmap(path, cropWhitespace, false, orientation, out origin);
 | 
	
		
			
				|  |  | +            return GetBitmap(path, cropWhitespace, false, orientation, out _);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          private SKBitmap OrientImage(SKBitmap bitmap, SKEncodedOrigin origin)
 | 
	
	
		
			
				|  | @@ -517,14 +515,14 @@ namespace Jellyfin.Drawing.Skia
 | 
	
		
			
				|  |  |          /// <inheritdoc/>
 | 
	
		
			
				|  |  |          public string EncodeImage(string inputPath, DateTime dateModified, string outputPath, bool autoOrient, ImageOrientation? orientation, int quality, ImageProcessingOptions options, ImageFormat selectedOutputFormat)
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  | -            if (string.IsNullOrWhiteSpace(inputPath))
 | 
	
		
			
				|  |  | +            if (inputPath.Length == 0)
 | 
	
		
			
				|  |  |              {
 | 
	
		
			
				|  |  | -                throw new ArgumentNullException(nameof(inputPath));
 | 
	
		
			
				|  |  | +                throw new ArgumentException("String can't be empty.", nameof(inputPath));
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            if (string.IsNullOrWhiteSpace(inputPath))
 | 
	
		
			
				|  |  | +            if (outputPath.Length == 0)
 | 
	
		
			
				|  |  |              {
 | 
	
		
			
				|  |  | -                throw new ArgumentNullException(nameof(outputPath));
 | 
	
		
			
				|  |  | +                throw new ArgumentException("String can't be empty.", nameof(outputPath));
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              var skiaOutputFormat = GetImageFormat(selectedOutputFormat);
 | 
	
	
		
			
				|  | @@ -538,7 +536,7 @@ namespace Jellyfin.Drawing.Skia
 | 
	
		
			
				|  |  |              {
 | 
	
		
			
				|  |  |                  if (bitmap == null)
 | 
	
		
			
				|  |  |                  {
 | 
	
		
			
				|  |  | -                    throw new ArgumentOutOfRangeException($"Skia unable to read image {inputPath}");
 | 
	
		
			
				|  |  | +                    throw new InvalidDataException($"Skia unable to read image {inputPath}");
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  var originalImageSize = new ImageDimensions(bitmap.Width, bitmap.Height);
 |