GithubHelp home page GithubHelp logo

kevin-bronsdijk / kraken-net Goto Github PK

View Code? Open in Web Editor NEW
19.0 6.0 5.0 12.54 MB

Official Kraken.io .Net client

Home Page: https://kraken.io

License: GNU General Public License v2.0

Batchfile 0.12% F# 1.87% C# 98.01%
kraken-net optimize-images api-wrapper dotnet

kraken-net's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

kraken-net's Issues

Move from appveyor to Azure DevOps

  • Merge solutions into one
  • Create new powershell based build script
  • What to do with the readme update?
  • Create Build in Azure DevOps
  • Create new nuget package template with publish (master only)

Issues with .NET 4.7.2

I am getting when trying to call:
var connection = Connection.Create(Kraken_Key, Kraken_Secret);

Could not load file or assembly 'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

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

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;
}
}

Possible Issue with uploading stream

Hi,

great package. I have some image url functions working. But this snippet I cannot get to work.
` public string ResizeImage(Stream input,int width,int height,string filename,string folder)
{

        string result = "";

            var connection = Connection.Create(ApiKey, ApiSecret);

            Client client = new Client(connection);
            var dataStore = new  Kraken.Model.Azure.DataStore(AzureAccount, AzureKey, AzureContainer, folder + "/" + filename);
            dataStore.AddHeaders("Cache-Control", "max-age=2222");

            using (MemoryStream ms = new MemoryStream())
            {
                input.Position = 0;
                input.CopyTo(ms);
                ms.Position = 0;


              var response =  client.OptimizeWait(ms.ToArray(),filename, new Kraken.Model.Azure.OptimizeUploadWaitRequest(dataStore) {
                    ResizeImage = new Kraken.Model.ResizeImage
                    {
                        Width = width,
                        Height = height,
                        Strategy= Kraken.Model.Strategy.Auto
                     }
                });

                if (response.Result.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    //response.Result.Body.KrakedUrl
                    result = AzureURL +"/"+ AzureContainer +"/"+ folder + "/" + filename;
                }
            }

        return result;

    }`

The stream contains data, any idea what I´m doing wrong?

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

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 ?

Timeout during upload due to default HttpClient.Timeout property

HttpClient.Timeout defaults to a 100 second timeout. I have a reproducible problem where this timeout period is not long enough for Kraken to finish processing the request. It could be due to throttling; I am not sure. However, if I use reflection to set the timeout of the private HttpClient _client field on the Connection object to System.Threading.Timeout.InfiniteTimeSpan, then the request completes successfully.

This is a reproducible problem given the same inputs. I suggest that you set the Timeout property to infinite by default, or add an argument for a custom timeout value on the Connection.Create static method. Keep in mind that since there are already overloads of the conversion methods that accept a CancellationToken, a custom timeout can be implemented, as described by MS's documentation:

See https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient.timeout?view=net-5.0 :

The same timeout will apply for all requests using this HttpClient instance. You may also set different timeouts for individual requests using a CancellationTokenSource on a task. Note that only the shorter of the two timeouts will apply.

Strategy Crop and Fit are missing X and Y?

Hi, I can't see how to set X and Y when using strategy crop.
Can it be added so we can use it with "Fit" and "Crop"?
"resize": {
"strategy": "crop",
"x": 200,
"y": 200,
"width": 500,
"height": 500,
"scale": 50
}

Thanks

Target Netstandard

Hey guys,

I was wondering if it was possible to get a netstandard build packaged for nuget. Right now, using kraken-net I have to use netstandard2.0 so I can target the existing package.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.