Ramesh Mukka Thanks for posting your question in Microsoft Q&A. From the description, I assume you are trying to reduce size of the file using SixLabors.ImageSharp
package using C# script in portal and follow code snippet similar in https://github.com/Azure-Samples/function-image-upload-resize/blob/master/ImageFunctions/Thumbnail.cs.
I was able to test this function code with package version 1.0.3
and you are right that this is not as expected. Since this seems to be issue with SixLabors.ImageSharp
package and its version or runtime (not actually Azure Function), please refer https://docs.sixlabors.com/articles/imagesharp/resize.html about this operation and if it doesn't help, please reach out to https://github.com/SixLabors/ImageSharp/issues repo for assistance (experts from the package team can help).
In general, we don't recommend using C# script (only for convenient) and consider using In-process or Isolated model for production apps. I used the latest version of this package using in process model in Visual Studio and didn't observe the same behavior. Checkout the following:
Function1.cs
using System.IO;
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Logging;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Formats.Png;
using SixLabors.ImageSharp.Processing;
using Image = SixLabors.ImageSharp.Image;
namespace CSXSample
{
public class Function1
{
[FunctionName("Function1")]
public void Run([BlobTrigger("samples-workitems/{name}", Connection = "AzureWebStorage")]Stream myBlob, string name, ILogger log, [Blob("outcontainer/{name}", FileAccess.Write)] Stream imageSmall)
{
using (var image = Image.Load(myBlob))
{
image.Mutate(C => C.Resize(500, 500));
image.SaveAsPng(imageSmall, new PngEncoder());
}
log.LogInformation($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
}
}
}
CSXSample.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Storage.Blobs" Version="12.13.1" />
<PackageReference Include="Azure.Storage.Files.Shares" Version="12.1.0" />
<PackageReference Include="Azure.Storage.Queues" Version="12.11.1" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Azure" Version="1.5.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="6.0.1" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.2.0" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.2" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
So, I suggest you validate the code in in-process or isolated model with the latest version and adjust resizing for your scenario. I hope this helps and let me know if any questions.
If you found the answer to your question helpful, please take a moment to mark it as Yes
for others to benefit from your experience. Or simply add a comment tagging me and would be happy to answer your questions.