Kraken.io图像调整大小

时间:2017-08-09 08:28:26

标签: c# image-resizing kraken-image-optimizer

using Kraken;
using Kraken.Http;
using Kraken.Model;
public void ResizeSelectedImages()
        {
            var filesToResize = FilesInFolderListBox.SelectedItems;
            var connection = Connection.Create(Properties.Settings.Default.krakenkey, Properties.Settings.Default.krakensecret, Properties.Settings.Default.SandBoxMode);
            var client = new Client(connection);

            foreach (var file in filesToResize)
            {
                var response = client.OptimizeWait(new Uri("http://awesome-website.com/images/header.png"),
                                new OptimizeUploadWaitRequest()
                                {
                                    ResizeImage = new ResizeImage
                                    {
                                        Width = 100,
                                        Height = 75,
                                        Strategy = Strategy.Crop
                                    }
                                }
                        );

            }
        }

很明显我想尝试做什么,这几乎是从kraken.io文档中复制的代码。这给了我的是从“new OptimizeUploadWaitRequest()”开始的很多红线,说“参数2:从System.Threading.CancellationToken中的Kraken.Model.OptimizeUploadWaitRequest转换不可能”......

Kraken的其他方面到目前为止工作(从我的本地目录中获取图像,“优化”它们并将它们上传到FTP ..不知怎的,虽然这个不起作用...谷歌搜索都是关于某些海至少有6个武器的生物......

有谁知道这个问题,可以帮助我吗?或者看看我做错了什么?或者指出我正确的方向.. 我尝试重新安装软件包(uri将是file.toString(),但这不重要,并且在我从文档中复制之前已经给出了错误)

1 个答案:

答案 0 :(得分:1)

确定解决了我自己的问题..我刚刚接受了wronng任务..而且kraken.io网站上的文档有问题。

根据文档你应该给它一个uri和optimizeUploadWaitRequest ..而根据元数据theres没有采取uri +和optimizeUploadWaitRequest ..只有uri和cancelToken或filepath和optimizeUploadWaitRequest ..所以。是的..应该先看看那里。

        //public Task<IApiResponse<OptimizeResult>> Optimize(byte[] image, string filename, IOptimizeUploadRequest optimizeRequest, CancellationToken cancellationToken);
        //public Task<IApiResponse<OptimizeResult>> Optimize(string filePath, IOptimizeSetUploadRequest optimizeRequest);
        //public Task<IApiResponse<OptimizeResult>> Optimize(byte[] image, string filename, IOptimizeSetUploadRequest optimizeRequest, CancellationToken cancellationToken);
        //public Task<IApiResponse<OptimizeResult>> Optimize(byte[] image, string filename, IOptimizeSetUploadRequest optimizeRequest);
        //public Task<IApiResponse<OptimizeResult>> Optimize(IOptimizeSetRequest optimizeSetRequest, CancellationToken cancellationToken);
        //public Task<IApiResponse<OptimizeResult>> Optimize(IOptimizeSetRequest optimizeSetRequest);
        //public Task<IApiResponse<OptimizeResult>> Optimize(IOptimizeRequest optimizeRequest, CancellationToken cancellationToken);
        //public Task<IApiResponse<OptimizeResult>> Optimize(IOptimizeRequest optimizeRequest);
        //public Task<IApiResponse<OptimizeResult>> Optimize(string filePath, IOptimizeSetUploadRequest optimizeRequest, CancellationToken cancellationToken);
        //public Task<IApiResponse<OptimizeResult>> Optimize(string filePath, IOptimizeUploadRequest optimizeRequest, CancellationToken cancellationToken);
        //public Task<IApiResponse<OptimizeResult>> Optimize(string filePath, IOptimizeUploadRequest optimizeRequest);
        //public Task<IApiResponse<OptimizeResult>> Optimize(byte[] image, string filename, IOptimizeUploadRequest optimizeRequest);
        //public Task<IApiResponse<OptimizeResult>> Optimize(string filePath, Uri callbackUrl, CancellationToken cancellationToken);
        //public Task<IApiResponse<OptimizeResult>> Optimize(string filePath, Uri callbackUrl);
        //public Task<IApiResponse<OptimizeResult>> Optimize(Uri imageUri, Uri callbackUrl);
        //public Task<IApiResponse<OptimizeResult>> Optimize(Uri imageUri, Uri callbackUrl, CancellationToken cancellationToken);
        //public Task<IApiResponse<OptimizeWaitResult>> OptimizeWait(string filePath, IOptimizeUploadWaitRequest optimizeWaitRequest);
        //public Task<IApiResponse<OptimizeWaitResult>> OptimizeWait(Uri imageUri);
        public Task<IApiResponse<OptimizeWaitResult>> OptimizeWait(Uri imageUri, CancellationToken cancellationToken);
        //public Task<IApiResponse<OptimizeSetWaitResults>> OptimizeWait(string filePath, IOptimizeSetUploadWaitRequest optimizeWaitRequest, CancellationToken cancellationToken);
        //public Task<IApiResponse<OptimizeSetWaitResults>> OptimizeWait(string filePath, IOptimizeSetUploadWaitRequest optimizeWaitRequest);
        //public Task<IApiResponse<OptimizeSetWaitResults>> OptimizeWait(byte[] image, string filename, IOptimizeSetUploadWaitRequest optimizeWaitRequest, CancellationToken cancellationToken);
        //public Task<IApiResponse<OptimizeSetWaitResults>> OptimizeWait(byte[] image, string filename, IOptimizeSetUploadWaitRequest optimizeWaitRequest);
        //public Task<IApiResponse<OptimizeSetWaitResults>> OptimizeWait(IOptimizeSetWaitRequest optimizeSetWaitRequest, CancellationToken cancellationToken);
        //public Task<IApiResponse<OptimizeSetWaitResults>> OptimizeWait(IOptimizeSetWaitRequest optimizeSetWaitRequest);
        //public Task<IApiResponse<OptimizeWaitResult>> OptimizeWait(string filePath);
        //public Task<IApiResponse<OptimizeWaitResult>> OptimizeWait(string filePath, CancellationToken cancellationToken);
        //public Task<IApiResponse<OptimizeWaitResult>> OptimizeWait(IOptimizeWaitRequest optimizeWaitRequest, CancellationToken cancellationToken);
        //public Task<IApiResponse<OptimizeWaitResult>> OptimizeWait(IOptimizeWaitRequest optimizeWaitRequest);
        //public Task<IApiResponse<OptimizeWaitResult>> OptimizeWait(byte[] image, string filename, IOptimizeUploadWaitRequest optimizeWaitRequest, CancellationToken cancellationToken);
        //public Task<IApiResponse<OptimizeWaitResult>> OptimizeWait(byte[] image, string filename, IOptimizeUploadWaitRequest optimizeWaitRequest);
        public Task<IApiResponse<OptimizeWaitResult>> OptimizeWait(string filePath, IOptimizeUploadWaitRequest optimizeWaitRequest, CancellationToken cancellationToken);
        //public Task<IApiResponse<UserResult>> UserStatus(CancellationToken cancellationToken);
        //public Task<IApiResponse<UserResult>> UserStatus();

如此生病只需要从那里拿出正确的一个 (这两个条目没有注释掉......为了清晰起见..我希望)

所以是的..和kraken似乎一样好..文件......不是最新的。