Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
saurabh5986 opened this issue Nov 29, 2019 · 1 comment

Comments

@saurabh5986
Copy link

saurabh5986 commented Nov 29, 2019

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants