Quantcast
Channel: magick Discussions Rss Feed
Viewing all articles
Browse latest Browse all 3693

New Post: Same output for different inputs

$
0
0
I am trying to create a function that will accept many file types but output a transparent PNG.
So far I have this bit of code:
public async Task<string> ConvertImage(byte[] data, bool replaceBlack)
{

    // Create our read settings
    var settings = new MagickReadSettings()
    {
        //Format = MagickFormat.Svg
        Width = 600,
        Height = 600
    };

    // Create our image
    using (var image = new MagickImage(data, settings))
    {

        // Create a new memory stream
        using (var memoryStream = new MemoryStream())
        {

            // Set to a png
            image.Format = MagickFormat.Png32;

            // Write to our stream
            image.Write(memoryStream);

            // Reset the memory stream position
            memoryStream.Position = 0;

            // Create a new blob block to hold our image
            var blockBlob = container.GetBlockBlobReference(Guid.NewGuid().ToString() + ".png");

            // Upload to azure
            await blockBlob.UploadFromStreamAsync(memoryStream);

            // Return the blobs url
            return blockBlob.StorageUri.PrimaryUri.ToString();
        }
    }
}
which is working perfectly with svg files, but when I try a png or ai file I just get a full transparent image.
Does anyone know why?

Viewing all articles
Browse latest Browse all 3693

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>