kevin-bronsdijk / kraken-net Goto Github PK
View Code? Open in Web Editor NEWOfficial Kraken.io .Net client
Home Page: https://kraken.io
License: GNU General Public License v2.0
Official Kraken.io .Net client
Home Page: https://kraken.io
License: GNU General Public License v2.0
https://kraken.io/docs/generating-image-sets#returning-the-optimized-original-size-image - as described here the is a "none" strategy. That is missing in the Enum.
Can we fix the square strategy to accept a "size" instead of a width and height? Currently issuing a square strategy request fails since Kraken.io API expects a "size" to be set instead, as per https://kraken.io/docs/image-resizing
"resize": {
"size": 100,
"strategy": "square"
}
Thanks!
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.
could you Please update the library to support Custom Image Quality feature with Lossy image optimization.?
As per specified in kraken documentation below.
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;
}
}
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?
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 ?
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.
The current implementation is not intuitive, implementing a Fluent Interface should resolve some of the issues.
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
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!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.