Kevin-Bronsdijk / kraken-net

Official Kraken.io .Net client
https://kraken.io
GNU General Public License v2.0
19 stars 5 forks source link

Not able to have multiple file resized in one request with image sets #21

Open saurabh5986 opened 4 years ago

saurabh5986 commented 4 years ago

I am trying to get multiple resize image using one api call using this approach. Image Sets Sample, Upload and Wait:

var request = new OptimizeSetUploadWaitRequest() { // Request level settings Lossy = true, }; request.AddSet(new ResizeImageSet { // Individual settings Name = "set1", Height = 10, Width = 10, Lossy = false }); request.AddSet(new ResizeImageSet { // Individual settings Name = "set2", Height = 15, Width = 15, SamplingScheme = SamplingScheme.S444 });

var response = client.OptimizeWait("c:\your-image-location-on-disk.jpeg", request);

if(response.Result.StatusCode == HttpStatusCode.OK) { foreach (var item in result.Body.Results) { var url = item.KrakedUrl; } }

My code is :

    public async Task<byte[]> ResizeMultiple(string imageUrl, Dictionary<int, string> sizesAndFileNames)
    {
        try
        {
            var request = new OptimizeSetUploadWaitRequest() { Lossy = false };

            foreach (var sizeAndFileName in sizesAndFileNames)
            {
                var size = sizeAndFileName.Key;
                var fileName = sizeAndFileName.Value;
                var enhance = size < 200;

                request.AddSet(new ResizeImageSet { Name = fileName, Height = size, Width = size, Enhance = enhance, Lossy = false });
            }

            var client = CreateClient();

            var result = await client.OptimizeWait(imageUrl, request);

            return null;
            //return await GetMultipleProcessedImage(result);
        }
        catch (Exception ex)
        {
            _logger.Warning("Error getting from kraken.io");
            throw ex;
        }
    }

I am getting result.success true but nothing about the resized images. also result.Body.Result count is also 0. Image url : https://dmchyblmtj6td.cloudfront.net/content/products/4676-1-wilton-in-black-crystal-satin.jpg I am doing anything wrong ?

Fraaankes commented 4 years ago

Im seeing the same behaviour.

The API responds with a 200 OK, and injecting Fiddler as a proxy, I can see the results in the body does not match the result type OptimizeSetWaitResult So we end up with an empty list.

Pushing the results to external storage seem to be the only way to get a hold of the images until this gets fixed.