public void TestSprite() { ImageUploadParams uploadParams = new ImageUploadParams() { File = new FileDescription(m_testImagePath), Tags = "logo,beauty", PublicId = "logo1", Transformation = new Transformation().Width(200).Height(100) }; m_cloudinary.Upload(uploadParams); uploadParams.PublicId = "logo2"; uploadParams.Transformation = new Transformation().Width(100).Height(100); m_cloudinary.Upload(uploadParams); uploadParams.PublicId = "logo3"; uploadParams.Transformation = new Transformation().Width(100).Height(300); m_cloudinary.Upload(uploadParams); SpriteParams sprite = new SpriteParams("logo"); SpriteResult result = m_cloudinary.MakeSprite(sprite); Assert.NotNull(result); Assert.NotNull(result.ImageInfos); Assert.AreEqual(3, result.ImageInfos.Count); Assert.Contains("logo1", result.ImageInfos.Keys); Assert.Contains("logo2", result.ImageInfos.Keys); Assert.Contains("logo3", result.ImageInfos.Keys); }
public async Task <SpriteResult> MakeSpriteAsync(SpriteParams parameters) { using (var response = await Api.CallAsync(HttpMethod.Post, Api.ApiUrlImgUpV.Action("sprite").BuildUrl(), parameters.ToParamsDictionary(), null, null)) { return(await SpriteResult.Parse(response)); } }
/// <summary> /// Eagerly generate sprites /// </summary> /// <param name="parameters">Parameters for sprite generation</param> /// <returns>Result of sprite generation</returns> public SpriteResult MakeSprite(SpriteParams parameters) { UrlBuilder urlBuilder = new UrlBuilder( m_api.ApiUrlImgUpV. Action("sprite"). BuildUrl()); using (HttpWebResponse response = m_api.Call( HttpMethod.POST, urlBuilder.ToString(), parameters.ToParamsDictionary(), null)) { SpriteResult result = SpriteResult.Parse(response); return(result); } }
private void AssertSprite(SpriteResult result, string fileFormat) { Assert.NotNull(result?.ImageInfos); Assert.NotNull(result.ImageUrl); StringAssert.EndsWith(fileFormat, result.ImageUrl.ToString()); Assert.AreEqual(result.ImageUrl, result.ImageUrl); Assert.NotNull(result.CssUrl); Assert.AreEqual(result.CssUrl, result.CssUrl); Assert.NotNull(result.JsonUrl); Assert.AreEqual(result.JsonUrl, result.JsonUrl); Assert.NotNull(result.SecureCssUrl); Assert.AreEqual(result.SecureCssUrl, result.SecureCssUrl); Assert.NotNull(result.SecureImageUrl); Assert.NotNull(result.SecureJsonUrl); }
private void AssertSprite(SpriteResult result, IEnumerable <string> publicIds, string fileFormat) { Assert.NotNull(result?.ImageInfos); Assert.NotNull(result.ImageUrl); StringAssert.EndsWith(fileFormat, result.ImageUrl.ToString()); CollectionAssert.AreEqual(publicIds, result.ImageInfos.Keys); Assert.AreEqual(result.ImageUrl, result.ImageUrl); Assert.NotNull(result.CssUrl); Assert.AreEqual(result.CssUrl, result.CssUrl); Assert.NotNull(result.JsonUrl); Assert.AreEqual(result.JsonUrl, result.JsonUrl); Assert.NotNull(result.SecureCssUrl); Assert.AreEqual(result.SecureCssUrl, result.SecureCssUrl); Assert.NotNull(result.SecureImageUrl); Assert.NotNull(result.SecureJsonUrl); }
public void TestSprite() { var publicId1 = GetUniquePublicId(StorageType.sprite); var publicId2 = GetUniquePublicId(StorageType.sprite); var publicId3 = GetUniquePublicId(StorageType.sprite); var spriteTag = GetMethodTag(); ImageUploadParams uploadParams = new ImageUploadParams() { File = new FileDescription(m_testImagePath), Tags = $"{spriteTag},{m_apiTag}", PublicId = publicId1, Transformation = m_resizeTransformation }; m_cloudinary.Upload(uploadParams); uploadParams.PublicId = publicId2; uploadParams.Transformation = m_updateTransformation; m_cloudinary.Upload(uploadParams); uploadParams.PublicId = publicId3; uploadParams.Transformation = m_simpleTransformation; m_cloudinary.Upload(uploadParams); SpriteParams sprite = new SpriteParams(spriteTag) { Format = FILE_FORMAT_JPG }; SpriteResult result = m_cloudinary.MakeSprite(sprite); AddCreatedPublicId(StorageType.sprite, result.PublicId); Assert.NotNull(result); Assert.NotNull(result.ImageInfos); Assert.AreEqual(3, result.ImageInfos.Count); StringAssert.EndsWith(FILE_FORMAT_JPG, result.ImageUri.ToString()); Assert.Contains(publicId1, result.ImageInfos.Keys); Assert.Contains(publicId2, result.ImageInfos.Keys); Assert.Contains(publicId3, result.ImageInfos.Keys); }
public void TestSpriteTransformation() { var publicId1 = GetUniquePublicId(StorageType.sprite); var publicId2 = GetUniquePublicId(StorageType.sprite); var publicId3 = GetUniquePublicId(StorageType.sprite); var spriteTag = GetMethodTag(); ImageUploadParams uploadParams = new ImageUploadParams() { File = new FileDescription(m_testImagePath), Tags = $"{spriteTag},{m_apiTag}", PublicId = publicId1, Transformation = m_simpleTransformation }; m_cloudinary.Upload(uploadParams); uploadParams.PublicId = publicId2; uploadParams.Transformation = m_updateTransformation; m_cloudinary.Upload(uploadParams); uploadParams.PublicId = publicId3; uploadParams.Transformation = m_explicitTransformation; m_cloudinary.Upload(uploadParams); SpriteParams sprite = new SpriteParams(spriteTag) { Transformation = m_resizeTransformation }; SpriteResult result = m_cloudinary.MakeSprite(sprite); AddCreatedPublicId(StorageType.sprite, result.PublicId); Assert.NotNull(result); Assert.NotNull(result.ImageInfos); foreach (var item in result.ImageInfos) { Assert.AreEqual(m_resizeTransformationWidth, item.Value.Width); Assert.AreEqual(m_resizeTransformationHeight, item.Value.Height); } }
public void TestSpriteTransformation() { ImageUploadParams uploadParams = new ImageUploadParams() { File = new FileDescription(m_testImagePath), Tags = "logotrans", PublicId = "logotrans1", Transformation = new Transformation().Width(200).Height(100) }; m_cloudinary.Upload(uploadParams); uploadParams.PublicId = "logotrans2"; uploadParams.Transformation = new Transformation().Width(100).Height(100); m_cloudinary.Upload(uploadParams); uploadParams.PublicId = "logotrans3"; uploadParams.Transformation = new Transformation().Width(100).Height(300); m_cloudinary.Upload(uploadParams); SpriteParams sprite = new SpriteParams("logotrans"); sprite.Transformation = new Transformation().Width(100).Height(100).Crop("scale"); SpriteResult result = m_cloudinary.MakeSprite(sprite); Assert.NotNull(result); Assert.NotNull(result.ImageInfos); foreach (var item in result.ImageInfos) { Assert.AreEqual(100, item.Value.Width); Assert.AreEqual(100, item.Value.Height); } }