diff --git a/.github/workflows/dotnet-core.yml b/.github/workflows/dotnet-core.yml index 1797ef8..7da4a2c 100644 --- a/.github/workflows/dotnet-core.yml +++ b/.github/workflows/dotnet-core.yml @@ -41,6 +41,8 @@ jobs: 3.1.x 5.0.x 6.0.x + 7.0.x + 8.0.x - name: Build Release run: dotnet build Imagekit.sln -c Release /p:ContinuousIntegrationBuild=true @@ -57,7 +59,7 @@ jobs: run: dotnet pack Imagekit.sln -c Release --no-build --output ${{ env.NUGET_OUTPUT_PATH }} - name: 'Upload Artifact' - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: ${{ env.ATTRIBUTE_NAME }} path: ${{ env.NUGET_OUTPUT_PATH }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ce775e..25fd627 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [5.0.0] + +### Breaking changes + +**Overlay syntax update** +* In version 5.0.0, we've removed the old overlay syntax parameters for transformations, such as `oi`, `ot`, `obg`, and [more](https://docs.imagekit.io/features/image-transformations/overlay). These parameters are deprecated and will start returning errors when used in URLs. Please migrate to the new layers syntax that supports overlay nesting, provides better positional control, and allows more transformations at the layer level. You can start with [examples](https://docs.imagekit.io/features/image-transformations/overlay-using-layers#examples) to learn quickly. +* You can migrate to the new layers syntax using the `raw` transformation parameter. + +### Added +- Parameters `EffectShadow` and `EffectGradient` for url generation. +- Upload options + - `transformation` for applying `pre` and `post` transformations. + - `checks` to perform server-side validations before file uploads. + - `isPublished` determines whether the file should be uploaded as published. +- Update parameter + - `publish` to configure the publication status of a file and its versions. + ## [4.0.1] ### Fixed - https://github.com/imagekit-developer/imagekit-dotnet/issues/50 diff --git a/ImageKitSample/Program.cs b/ImageKitSample/Program.cs index 58e91f1..093bb84 100644 --- a/ImageKitSample/Program.cs +++ b/ImageKitSample/Program.cs @@ -41,32 +41,6 @@ static void Main(string[] args) Rotation(90). Blur(10). Named("some_name"). - OverlayX(35). - OverlayY(35). - OverlayFocus("bottom"). - OverlayHeight(20). - OverlayHeight(20). - OverlayImage("/folder/file_name.jpg"). // leading slash case - OverlayImageTrim(false). - OverlayImageAspectRatio("4:3"). - OverlayImageBackground("0F0F0F"). - OverlayImageBorder("10_0F0F0F"). - OverlayImageDpr(2). - OverlayImageQuality(50). - OverlayImageCropping("force"). - OverlayText("two words"). - OverlayTextFontSize(20). - OverlayTextFontFamily("Open Sans"). - OverlayTextColor("00FFFF"). - OverlayTextTransparency(5). - OverlayTextTypography("b"). - OverlayBackground("00AAFF55"). - OverlayTextEncoded("b3ZlcmxheSBtYWRlIGVhc3k%3D"). - OverlayTextWidth(50). - OverlayTextBackground("00AAFF55"). - OverlayTextPadding(40). - OverlayTextInnerAlignment("left"). - OverlayRadius(10). Progressive(true). Lossless(true). Trim(5). @@ -78,6 +52,8 @@ static void Main(string[] args) EffectUsm("2-2-0.8-0.024"). EffectContrast(true). EffectGray(). + EffectShadow(). + EffectGradient(). Original(). Raw("h-200,w-300,l-image,i-logo.png,l-end"); @@ -153,6 +129,18 @@ static void Main(string[] args) maxTags = 5, minConfidence = 95 }; + TransformationObject transformationObject = new TransformationObject + { + type = "transformation", + value = "w-100" + }; + List postTransformations = new List(); + postTransformations.Add(transformationObject); + UploadTransformation uploadTransformation = new UploadTransformation + { + pre = "l-text,i-Imagekit,fs-50,l-end", + post = postTransformations, + }; ext.Add(bck1); ext.Add(autoTags); ob.extensions = ext; @@ -164,6 +152,7 @@ static void Main(string[] args) ob.overwriteAITags = true; ob.overwriteTags = true; ob.overwriteCustomMetadata = true; + ob.transformation= uploadTransformation; Result resp2 = imagekit.Upload(ob); // Get Base64 diff --git a/Imagekit.UnitTests/ImageKitTestCasesNonAsync.cs b/Imagekit.UnitTests/ImageKitTestCasesNonAsync.cs index 7df6226..4e57c7b 100644 --- a/Imagekit.UnitTests/ImageKitTestCasesNonAsync.cs +++ b/Imagekit.UnitTests/ImageKitTestCasesNonAsync.cs @@ -57,32 +57,6 @@ public void UrlValidation() Rotation(90). Blur(10). Named("some_name"). - OverlayX(35). - OverlayY(35). - OverlayFocus("bottom"). - OverlayHeight(20). - OverlayHeight(20). - OverlayImage("/folder/file.jpg"). // leading slash case - OverlayImageTrim(false). - OverlayImageAspectRatio("4:3"). - OverlayImageBackground("0F0F0F"). - OverlayImageBorder("10_0F0F0F"). - OverlayImageDpr(2). - OverlayImageQuality(50). - OverlayImageCropping("force"). - OverlayText("two words"). - OverlayTextFontSize(20). - OverlayTextFontFamily("Open Sans"). - OverlayTextColor("00FFFF"). - OverlayTextTransparency(5). - OverlayTextTypography("b"). - OverlayBackground("00AAFF55"). - OverlayTextEncoded("b3ZlcmxheSBtYWRlIGVhc3k%3D"). - OverlayTextWidth(50). - OverlayTextBackground("00AAFF55"). - OverlayTextPadding(40). - OverlayTextInnerAlignment("left"). - OverlayRadius(10). Progressive(true). Lossless(true). Trim(5). @@ -94,13 +68,15 @@ public void UrlValidation() EffectUsm("2-2-0.8-0.024"). EffectContrast(true). EffectGray(). + EffectShadow("bl-15"). + EffectGradient("from-lightskyblue_to-mintcream"). Original(). - Raw("h-200,w-300,l-image,i-logo.png,l-end") + Raw("l-text,i-Imagekit,fs-50,l-end") ; string imageURL = imagekit.Url(trans).Path(path).TransformationPosition("query").Generate(); - Assert.Equal("https://endpoint_url.io/default-image.jpg?tr=w-400%2Ch-300%2Car-4-3%2Cq-40%2Cc-force%2Ccm-extract%2Cfo-left%2Cf-jpeg%2Cbg-A94D34%2Cb-5-A94D34%2Crt-90%2Cbl-10%2Cn-some_name%2Cox-35%2Coy-35%2Cofo-bottom%2Coh-20%2Coi-folder%40%40file.jpg%2Coit-false%2Coiar-4%3A3%2Coibg-0F0F0F%2Coib-10_0F0F0F%2Coidpr-2%2Coiq-50%2Coic-force%2Cot-two%20words%2Cots-20%2Cotf-Open%20Sans%2Cotc-00FFFF%2Coa-5%2Cott-b%2Cobg-00AAFF55%2Cote-b3ZlcmxheSBtYWRlIGVhc3k%253D%2Cotw-50%2Cotbg-00AAFF55%2Cotp-40%2Cotia-left%2Cor-10%2Cpr-true%2Clo-true%2Ct-5%2Cmd-true%2Ccp-true%2Cdi-folder%40%40file.jpg%2Cdpr-3%2Ce-sharpen-10%2Ce-usm-2-2-0.8-0.024%2Ce-contrast-true%2Ce-grayscale-true%2Corig-true%2Ch-200%2Cw-300%2Cl-image%2Ci-logo.png%2Cl-end", imageURL); + Assert.Equal("https://endpoint_url.io/default-image.jpg?tr=w-400%2Ch-300%2Car-4-3%2Cq-40%2Cc-force%2Ccm-extract%2Cfo-left%2Cf-jpeg%2Cbg-A94D34%2Cb-5-A94D34%2Crt-90%2Cbl-10%2Cn-some_name%2Cpr-true%2Clo-true%2Ct-5%2Cmd-true%2Ccp-true%2Cdi-folder%40%40file.jpg%2Cdpr-3%2Ce-sharpen-10%2Ce-usm-2-2-0.8-0.024%2Ce-contrast-true%2Ce-grayscale-true%2Ce-shadow-bl-15%2Ce-gradient-from-lightskyblue_to-mintcream%2Corig-true%2Cl-text%2Ci-Imagekit%2Cfs-50%2Cl-end", imageURL); } @@ -128,7 +104,7 @@ public void UrlValidation1() [Fact] public void GetFileRequest_DefaultNonAsync() - { + { GetFileListRequest ob = new GetFileListRequest { Limit = 10, diff --git a/Imagekit.UnitTests/Imagekit.UnitTests.csproj b/Imagekit.UnitTests/Imagekit.UnitTests.csproj index aa2b51f..0c21e08 100644 --- a/Imagekit.UnitTests/Imagekit.UnitTests.csproj +++ b/Imagekit.UnitTests/Imagekit.UnitTests.csproj @@ -1,7 +1,7 @@  - net5.0;net6.0;netcoreapp3.1;net461 + net7.0;net5.0;net6.0;netcoreapp3.1 8 true false @@ -25,27 +25,29 @@ 5 - + 1701;1702;NU5125;NU5048; + 5 - + 1701;1702;NU5125;NU5048; + 5 - + 1701;1702;NU5125;NU5048; - + 1701;1702;NU5125;NU5048; - + 1701;1702;NU5125;NU5048; - + 1701;1702;NU5125;NU5048; @@ -64,9 +66,6 @@ - - - diff --git a/Imagekit.UnitTests/Upload/UploadTestCasesAsync.cs b/Imagekit.UnitTests/Upload/UploadTestCasesAsync.cs index de10e98..2a24906 100644 --- a/Imagekit.UnitTests/Upload/UploadTestCasesAsync.cs +++ b/Imagekit.UnitTests/Upload/UploadTestCasesAsync.cs @@ -183,6 +183,17 @@ public void UploadFile_Default() name = "remove-bg", options = new options() { add_shadow = true, bg_color = "green" } }; + TransformationObject transformationObject = new TransformationObject + { + value = "w-100" + }; + List postTransformations = new List(); + postTransformations.Add(transformationObject); + UploadTransformation uploadTransformation = new UploadTransformation + { + pre = "l-text,i-Imagekit,fs-50,l-end", + post = postTransformations, + }; model1.Add(bck); ob.webhookUrl = "https://webhook.site/c78d617f-33bc-40d9-9e61-608999721e2e"; ob.useUniqueFileName = true; @@ -192,12 +203,14 @@ public void UploadFile_Default() ob.overwriteAITags = true; ob.overwriteTags = true; ob.overwriteCustomMetadata = true; + ob.transformation = uploadTransformation; + ob.checks = "'request.folder' : '/dummy-folder'"; + ob.isPublished = true; Hashtable model = new Hashtable { { "price", 2000 } }; ob.customMetadata = model; - var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); var httpResponse = new HttpResponseMessage { @@ -381,6 +394,34 @@ public void UpdateFile_Default() Assert.Equal(responseObj1, response.Raw); } + [Fact] + public void UpdateFile_Publish_Status() + { + FileUpdateRequest ob = new FileUpdateRequest + { + fileId = "file-Id", + + }; + PublishStatus publishStatus = new PublishStatus + { + isPublished = false + }; + ob.publish = publishStatus; + var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); + var httpResponse = new HttpResponseMessage + { + StatusCode = HttpStatusCode.OK, + Content = new StringContent(JsonConvert.SerializeObject(responseObj)) + }; + var httpClient = TestHelpers.GetTestHttpClient(httpResponse); + + var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); + + var response = (Result)restClient.UpdateFileDetailAsync(ob).Result; + var responseObj1 = JsonConvert.SerializeObject(responseObj); + Assert.Equal(responseObj1, response.Raw); + } + } } diff --git a/Imagekit.UnitTests/Upload/UploadTestCasesNonAsync.cs b/Imagekit.UnitTests/Upload/UploadTestCasesNonAsync.cs index 5ec58f7..4ed8340 100644 --- a/Imagekit.UnitTests/Upload/UploadTestCasesNonAsync.cs +++ b/Imagekit.UnitTests/Upload/UploadTestCasesNonAsync.cs @@ -193,6 +193,8 @@ public void UploadFile_DefaultNonAsync() ob.overwriteAITags = false; ob.overwriteTags = false; ob.overwriteCustomMetadata = true; + ob.checks = "'request.folder' : '/dummy-folder'"; + ob.isPublished = true; Hashtable model = new Hashtable { { "price", 2000 } @@ -381,6 +383,35 @@ public void UpdateFile_Default() var responseObj1 = JsonConvert.SerializeObject(responseObj); Assert.Equal(responseObj1, response.Raw); } + + [Fact] + public void UpdateFile_Publish_Status() + { + FileUpdateRequest ob = new FileUpdateRequest + { + fileId = "file-Id", + + }; + PublishStatus publishStatus = new PublishStatus + { + isPublished = false + }; + ob.publish = publishStatus; + + var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); + var httpResponse = new HttpResponseMessage + { + StatusCode = HttpStatusCode.OK, + Content = new StringContent(JsonConvert.SerializeObject(responseObj)) + }; + var httpClient = TestHelpers.GetTestHttpClient(httpResponse); + + var restClient = new RestClient(GOOD_PUBLICKEY, GOOD_URLENDPOINT, httpClient); + + var response = (Result)restClient.UpdateFileDetail(ob); + var responseObj1 = JsonConvert.SerializeObject(responseObj); + Assert.Equal(responseObj1, response.Raw); + } } } diff --git a/Imagekit/Helper/MultipartFormDataModel.cs b/Imagekit/Helper/MultipartFormDataModel.cs index fb7ef9a..cb670a7 100644 --- a/Imagekit/Helper/MultipartFormDataModel.cs +++ b/Imagekit/Helper/MultipartFormDataModel.cs @@ -8,6 +8,7 @@ using global::Imagekit.Models; using global::Imagekit.Util; using Newtonsoft.Json; + using System.Collections.Generic; public static class MultipartFormDataModel { @@ -105,6 +106,22 @@ public static MultipartFormDataContent Build(FileCreateRequest fileCreateRequest formdata.Add(new StringContent(jsonResult), "customMetadata"); } + if (fileCreateRequest.transformation != null) + { + string jsonResult = JsonConvert.SerializeObject(fileCreateRequest.transformation); + formdata.Add(new StringContent(jsonResult), "transformation"); + } + + if (fileCreateRequest.checks != null) + { + formdata.Add(new StringContent(fileCreateRequest.checks), "checks"); + } + + if (fileCreateRequest.isPublished.HasValue) + { + formdata.Add(new StringContent(fileCreateRequest.isPublished.Value.ToString().ToLower()), "isPublished"); + } + return formdata; } @@ -151,6 +168,12 @@ public static MultipartFormDataContent BuildUpdateFile(FileUpdateRequest fileCre formdata.Add(new StringContent(jSONresult), "customMetadata"); } + if (fileCreateRequest.publish != null) + { + string jSONresult = JsonConvert.SerializeObject(fileCreateRequest.publish); + formdata.Add(new StringContent(jSONresult), "publish"); + } + return formdata; } } diff --git a/Imagekit/Helper/TransformationTypes.cs b/Imagekit/Helper/TransformationTypes.cs index 30d3cb9..bd79692 100644 --- a/Imagekit/Helper/TransformationTypes.cs +++ b/Imagekit/Helper/TransformationTypes.cs @@ -130,195 +130,6 @@ public Transformation Named(string value) return this.Add("n", value); } - /// - /// - public Transformation OverlayImage(string value) - { - return this.Add("oi", value); - } - - /// - /// - public Transformation OverlayX(int value) - { - return this.Add("ox", this.ConvertCoordinateParam(value)); - } - - /// - /// - public Transformation OverlayY(int value) - { - return this.Add("oy", this.ConvertCoordinateParam(value)); - } - - /// - /// - public Transformation OverlayFocus(string value) - { - return this.Add("ofo", value); - } - - /// - /// - public Transformation OverlayHeight(int value) - { - return this.Add("oh", value); - } - - /// - /// - public Transformation OverlayWidth(int value) - { - return this.Add("ow", value); - } - - /// - /// - public Transformation OverlayText(string value) - { - return this.Add("ot", value); - } - - /// - /// - public Transformation OverlayTextFontSize(int value) - { - return this.Add("ots", value); - } - - /// - /// - public Transformation OverlayTextFontFamily(string value) - { - return this.Add("otf", value); - } - - /// - /// - public Transformation OverlayTextColor(string value) - { - return this.Add("otc", value); - } - - /// - /// - public Transformation OverylayAlpha(int value) - { - return this.Add("oa", value); - } - - /// - /// - public Transformation OverlayTextTypography(string value) - { - return this.Add("ott", value); - } - - /// - /// - public Transformation OverlayTextTransparency(int value) - { - return this.Add("oa", value); - } - - /// - /// - public Transformation OverlayTextBackground(string value) - { - return this.Add("otbg", value); - } - - /// - /// - public Transformation OverlayTextEncoded(string value) - { - return this.Add("ote", value); - } - - /// - /// - public Transformation OverlayTextWidth(int value) - { - return this.Add("otw", value); - } - - /// - /// - public Transformation OverlayTextPadding(int value) - { - return this.Add("otp", value); - } - - /// - /// - public Transformation OverlayTextInnerAlignment(string value) - { - return this.Add("otia", value); - } - - /// - /// - public Transformation OverlayRadius(int value) - { - return this.Add("or", value); - } - - /// - /// - public Transformation OverlayBackground(string value) - { - return this.Add("obg", value); - } - - /// - /// - public Transformation OverlayImageTrim(bool value) - { - return this.Add("oit", value.ToString().ToLower()); - } - - /// - /// - public Transformation OverlayImageAspectRatio(string value) - { - return this.Add("oiar", value); - } - - /// - /// - public Transformation OverlayImageBackground(string value) - { - return this.Add("oibg", value); - } - - /// - /// - public Transformation OverlayImageBorder(string value) - { - return this.Add("oib", value); - } - - /// - /// - public Transformation OverlayImageDpr(object value) - { - return this.Add("oidpr", value); - } - - /// - /// - public Transformation OverlayImageQuality(int value) - { - return this.Add("oiq", value); - } - - /// - /// - public Transformation OverlayImageCropping(string value) - { - return this.Add("oic", value); - } - /// /// public Transformation Progressive(bool value) @@ -407,6 +218,32 @@ public Transformation EffectGray() return this.Add("e-grayscale", "true"); } + /// + public Transformation EffectShadow() + { + return this.Add("e-shadow", string.Empty); + } + + /// + /// + public Transformation EffectShadow(string value) + { + return this.Add("e-shadow", value); + } + + /// + public Transformation EffectGradient() + { + return this.Add("e-gradient", string.Empty); + } + + /// + /// + public Transformation EffectGradient(string value) + { + return this.Add("e-gradient", value); + } + /// public Transformation Original() { diff --git a/Imagekit/Imagekit.csproj b/Imagekit/Imagekit.csproj index 888bcc6..013cc8b 100644 --- a/Imagekit/Imagekit.csproj +++ b/Imagekit/Imagekit.csproj @@ -4,7 +4,7 @@ Library Imagekit Imagekit - net5.0;net6.0;netcoreapp3.1;netstandard2.0;net461 + net7.0;net5.0;net6.0;netcoreapp3.1;netstandard2.0 8 © Imagekit Private Limited 2019 false @@ -17,10 +17,10 @@ Library to Integrate Imagekit.io Service. Imagekit true - 4.0.2 + 5.0.0 true false - 4.0.2 + 5.0.0 git@github.com:imagekit-developer/imagekit-dotnet.git true -Fixes @@ -50,32 +50,34 @@ 4 - + 1701;1702;1591;NU5125;NU5048;NU1504;NU5125;SYSLIB0014; $(WarningsAsErrors); + 4 - + 1701;1702;1591;NU5125;NU5048;NU1504;NU5125;SYSLIB0014; $(WarningsAsErrors); + 4 - + 1701;1702;1591;NU5125;NU5048;NU1504;NU5125;SYSLIB0014; $(WarningsAsErrors); - + 1701;1702;1591;NU5125;NU5048;NU1504;NU5125;SYSLIB0014; $(WarningsAsErrors); - + 1701;1702;1591;NU5125;NU5048;NU1504;NU5125;SYSLIB0014; $(WarningsAsErrors); - + 1701;1702;1591;NU5125;NU5048;NU1504;NU5125;SYSLIB0014; $(WarningsAsErrors); @@ -119,12 +121,4 @@ - - - - - - - - diff --git a/Imagekit/Models/FileCreateRequest.cs b/Imagekit/Models/FileCreateRequest.cs index 7b36e77..9787a6b 100644 --- a/Imagekit/Models/FileCreateRequest.cs +++ b/Imagekit/Models/FileCreateRequest.cs @@ -38,4 +38,10 @@ public class FileCreateRequest public object file { get; set; } public bool isPrivateFile { get; set; } + + public UploadTransformation transformation { get; set; } + + public string checks { get; set; } + + public bool? isPublished { get; set; } } \ No newline at end of file diff --git a/Imagekit/Models/FileUpdateRequest.cs b/Imagekit/Models/FileUpdateRequest.cs index e5b5999..9d1bd55 100644 --- a/Imagekit/Models/FileUpdateRequest.cs +++ b/Imagekit/Models/FileUpdateRequest.cs @@ -18,5 +18,7 @@ public class FileUpdateRequest public string customCoordinates { get; set; } public Hashtable customMetadata { get; set; } + + public PublishStatus publish { get; set; } } } diff --git a/Imagekit/Models/PublishStatus.cs b/Imagekit/Models/PublishStatus.cs new file mode 100644 index 0000000..be11998 --- /dev/null +++ b/Imagekit/Models/PublishStatus.cs @@ -0,0 +1,11 @@ +namespace Imagekit.Models +{ + using System.Collections.Generic; + + public class PublishStatus + { + public bool isPublished { get; set; } + public bool? includeFileVersions { get; set; } + } + +} diff --git a/Imagekit/Models/UploadTransformation.cs b/Imagekit/Models/UploadTransformation.cs new file mode 100644 index 0000000..dadc45e --- /dev/null +++ b/Imagekit/Models/UploadTransformation.cs @@ -0,0 +1,47 @@ +namespace Imagekit.Models +{ + using System.Collections.Generic; + + public class PostTransformation + { + public string type { get; set; } + public string value { get; set; } + } + + public enum Protocol + { + hls, + dash + } + + public class TransformationObject : PostTransformation + { + public string type { get; } = "transformation"; + public string value { get; set; } + } + + public class GifToVideoObject : PostTransformation + { + public string type { get; } = "gif-to-video"; + public string? value { get; set; } + } + public class ThumbnailObject : PostTransformation + { + public string type { get; } = "thumbnail"; + public string? value { get; set; } + } + + public class AbsObject : PostTransformation + { + public string type { get; } = "abs"; + public string value { get; set; } + public Protocol protocol { get; set; } + } + + public class UploadTransformation + { + public string? pre { get; set; } + public List? post { get; set; } + } + +} diff --git a/Imagekit/Util/Constants.cs b/Imagekit/Util/Constants.cs index 7d7e247..0700743 100644 --- a/Imagekit/Util/Constants.cs +++ b/Imagekit/Util/Constants.cs @@ -21,6 +21,6 @@ public static class Constants public const string UploadApiHost = "dasdasd.sadsdasd.io"; public const string FileApi = "/v1/files"; public const string UploadApi = "/api/v1/files/upload"; - public const string SdkVersion = "4.0.2"; + public const string SdkVersion = "5.0.0"; } } \ No newline at end of file diff --git a/README.md b/README.md index bdc952b..7442f66 100644 --- a/README.md +++ b/README.md @@ -82,8 +82,8 @@ Transformation trans = new Transformation() .Crop("force") .CropMode("extract") .Focus("left") -.Format("jpeg") -.Raw("h-200,w-300,l-image,i-logo.png,l-end"); +.Format("jpeg") +.Raw("l-text,i-Imagekit,fs-50,l-end"); string imageURL = imagekit.Url(trans).Path(path).TransformationPosition("query").Generate(); ``` @@ -91,7 +91,7 @@ string imageURL = imagekit.Url(trans).Path(path).TransformationPosition("query") This results in a URL like ```plaintext -https://ik.imagekit.io/default_image.jpg?tr=w-400%2Ch-300%2Car-4-3%2Cq_40%2Cc-force%2Ccm-extract%2Cfo-left%2Cf-jpeg%2Ch-200%2Cw-300%2Cl-image%2Ci-logo.png%2Cl-end +https://ik.imagekit.io/your_imagekit_id/default_image.jpg?tr=w-400%2Ch-300%2Car-4-3%2Cq-40%2Cc-force%2Ccm-extract%2Cfo-left%2Cf-jpeg%2Cl-text%2Ci-Imagekit%2Cfs-50%2Cl-end ``` **2\. Using full image URL** @@ -144,7 +144,7 @@ string imageURL = imagekit.Url(transformation) https://ik.imagekit.io/your_imagekit_id/endpoint/default_image.jpg?tr=h-300,w-400:rt-90 ``` -**2\. Sharpening and contrast transforms and a progressive JPG image** +**2\. Sharpening, contrast adjustment, shadow and gradient transformations, along with a progressive JPEG format image.** There are some transforms like [Sharpening](https://docs.imagekit.io/features/image-transformations/image-enhancement-and-color-manipulation) that can be added to the URL with or without any other value. @@ -155,7 +155,9 @@ Transformation trans = new Transformation() .Format("jpg") .Progressive(false) .EffectSharpen() - .EffectContrast(1); + .EffectContrast(1) + .EffectShadow() + .EffectGradient(); string imageURL = imagekit.Url(trans) .Src(src) @@ -165,7 +167,7 @@ string imageURL = imagekit.Url(trans) **Note**: Because `src` parameter was used, the transformation string gets added as a query parameter `tr`. ```plaintext -https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg?tr=f-jpg,pr-false,e-sharpen,e-contrast-1 +https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg?tr=f-jpg%2Cpr-false%2Ce-sharpen%2Ce-contrast-1%2Ce-shadow%2Ce-gradient ``` **3\. Signed URL that expires in 600 seconds with the default URL endpoint and other query parameters** @@ -283,6 +285,8 @@ The complete list of transformations supported and their usage in ImageKit can b | EffectUSM | e-usm | | EffectContrast | e-contrast | | EffectGray | e-grayscale | +| EffectShadow | e-shadow | +| EffectGradient | e-gradient | | Original | orig | | Raw | `replaced by the parameter value` | @@ -343,6 +347,17 @@ AutoTags autoTags = new AutoTags }; ext.Add(bck1); ext.Add(autoTags); +TransformationObject transformationObject = new TransformationObject +{ + value = "w-100" +}; +List postTransformations = new List(); +postTransformations.Add(transformationObject); +UploadTransformation uploadTransformation = new UploadTransformation +{ + pre = "l-text,i-Imagekit,fs-50,l-end", + post = postTransformations, +}; ob.extensions = ext; ob.webhookUrl = "https://webhook.site/c78d617f_33bc_40d9_9e61_608999721e2e"; ob.useUniqueFileName = true; @@ -352,7 +367,8 @@ ob.overwriteFile = true; ob.overwriteAITags = true; ob.overwriteTags = true; ob.overwriteCustomMetadata = true; - +ob.checks = "'file.size' < '1mb'" // To run server side checks before uploading files. Notice the quotes around file.size and 1mb. +ob.isPublished = true; Result resp2 = imagekit.Upload(ob); //Get Base64 @@ -450,6 +466,23 @@ updateob.webhookUrl = "https://webhook.site/c78d617f_33bc_40d9_9e61_608999721e2e Result updateresp = imagekit.UpdateFileDetail(updateob); ``` +**Update publish status** + +If `publish` is included in the update options, no other parameters are allowed. + +```cs +FileUpdateRequest updateob = new FileUpdateRequest +{ + fileId = "fileId", +}; +PublishStatus publishStatus = new PublishStatus +{ + isPublished = false +}; +updateob.publish = publishStatus; +Result updateresp = imagekit.UpdateFileDetail(updateob); +``` + **4\. Delete File** Accept the file ID and delete a file as per the [API documentation here](https://docs.imageKit.io/api-reference/media-api/delete-file).