From 93c972b44108260d20773fb53e2ef884b0097aac Mon Sep 17 00:00:00 2001 From: ANKUR DWIVEDI Date: Thu, 18 Jan 2024 08:26:13 +0530 Subject: [PATCH 01/17] added e-shadow and e-gradient --- lib/imagekitio/constants/supported_transformation.rb | 2 ++ lib/imagekitio/sdk/version.rb | 2 +- test/imagekit/url_test.rb | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/imagekitio/constants/supported_transformation.rb b/lib/imagekitio/constants/supported_transformation.rb index 06b3d1b..864cad9 100644 --- a/lib/imagekitio/constants/supported_transformation.rb +++ b/lib/imagekitio/constants/supported_transformation.rb @@ -56,6 +56,8 @@ module SupportedTransformation 'effect_usm': "e-usm", 'effect_contrast': "e-contrast", 'effect_gray': "e-grayscale", + 'effect_shadow': "e-shadow", + 'effect_gradient': "e-gradient", 'original': "orig", 'raw': 'raw', } diff --git a/lib/imagekitio/sdk/version.rb b/lib/imagekitio/sdk/version.rb index b409a95..baf95f8 100644 --- a/lib/imagekitio/sdk/version.rb +++ b/lib/imagekitio/sdk/version.rb @@ -1,5 +1,5 @@ module ImageKitIo module Sdk - VERSION = '2.3.0' + VERSION = '2.3.1' end end diff --git a/test/imagekit/url_test.rb b/test/imagekit/url_test.rb index 358351f..e0163ba 100644 --- a/test/imagekit/url_test.rb +++ b/test/imagekit/url_test.rb @@ -195,12 +195,14 @@ effect_usm: "2-2-0.8-0.024", effect_contrast: true, effect_gray: true, + effect_shadow: 'bl-15_st-40_x-10_y-N5', + effect_gradient: 'from-red_to-white', original: true, raw: 'w-200,h-200' },] } url = url_obj.generate_url(options) - expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400,ar-4-3,q-40,c-force,cm-extract,fo-left,f-jpeg,r-50,bg-A94D34,b-5-A94D34,rt-90,bl-10,n-some_name,ox-35,oy-35,ofo-bottom,oh-20,ow-20,oi-folder@@file.jpg,oit-false,oiar-4:3,oibg-0F0F0F,oib-10_0F0F0F,oidpr-2,oiq-50,oic-force,ot-two words,ots-20,otf-Open Sans,otc-00FFFF,oa-5,ott-b,obg-00AAFF55,ote-b3ZlcmxheSBtYWRlIGVhc3k%3D,otw-50,otbg-00AAFF55,otp-40,otia-left,or-10,pr-true,lo-true,t-5,md-true,cp-true,di-folder@@file.jpg,dpr-3,e-sharpen-10,e-usm-2-2-0.8-0.024,e-contrast-true,e-grayscale-true,orig-true,w-200,h-200/default-image.jpg") + expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400,ar-4-3,q-40,c-force,cm-extract,fo-left,f-jpeg,r-50,bg-A94D34,b-5-A94D34,rt-90,bl-10,n-some_name,ox-35,oy-35,ofo-bottom,oh-20,ow-20,oi-folder@@file.jpg,oit-false,oiar-4:3,oibg-0F0F0F,oib-10_0F0F0F,oidpr-2,oiq-50,oic-force,ot-two words,ots-20,otf-Open Sans,otc-00FFFF,oa-5,ott-b,obg-00AAFF55,ote-b3ZlcmxheSBtYWRlIGVhc3k%3D,otw-50,otbg-00AAFF55,otp-40,otia-left,or-10,pr-true,lo-true,t-5,md-true,cp-true,di-folder@@file.jpg,dpr-3,e-sharpen-10,e-usm-2-2-0.8-0.024,e-contrast-true,e-grayscale-true,e-shadow-bl-15_st-40_x-10_y-N5,e-gradient-from-red_to-white,orig-true,w-200,h-200/default-image.jpg") end it "test_generate_url_with_chained_transformation" do From 69e28d71cb1efb8cab9832a5b0ebce32453de985 Mon Sep 17 00:00:00 2001 From: ANKUR DWIVEDI Date: Thu, 18 Jan 2024 08:37:05 +0530 Subject: [PATCH 02/17] update ci --- .github/workflows/gempush.yml | 4 ++-- .github/workflows/test.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/gempush.yml b/.github/workflows/gempush.yml index e6acf51..e87460f 100644 --- a/.github/workflows/gempush.yml +++ b/.github/workflows/gempush.yml @@ -10,10 +10,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up Ruby 2.6 + - name: Set up Ruby 3.3 uses: ruby/setup-ruby@v1.126.0 with: - ruby-version: 2.6.5 + ruby-version: 3.3.0 - name: Run Test Cases run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6d942a0..832a2c9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,10 +9,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up Ruby 2.6 + - name: Set up Ruby 3.3 uses: ruby/setup-ruby@v1.126.0 with: - ruby-version: 2.6.5 + ruby-version: 3.3.0 - name: Build and test with Rake run: | gem install bundler From 14c30ce1becc142fdbc5b7a6cf0b7d95cdc50c18 Mon Sep 17 00:00:00 2001 From: ANKUR DWIVEDI Date: Thu, 18 Jan 2024 08:38:25 +0530 Subject: [PATCH 03/17] update ci --- .github/workflows/gempush.yml | 4 ++-- .github/workflows/test.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/gempush.yml b/.github/workflows/gempush.yml index e87460f..57d06c9 100644 --- a/.github/workflows/gempush.yml +++ b/.github/workflows/gempush.yml @@ -10,10 +10,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up Ruby 3.3 + - name: Set up Ruby 3.0 uses: ruby/setup-ruby@v1.126.0 with: - ruby-version: 3.3.0 + ruby-version: 3.0.0 - name: Run Test Cases run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 832a2c9..9fbf4d1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,10 +9,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up Ruby 3.3 + - name: Set up Ruby 3.0 uses: ruby/setup-ruby@v1.126.0 with: - ruby-version: 3.3.0 + ruby-version: 3.0.0 - name: Build and test with Rake run: | gem install bundler From 188fb85da26d2cd3d07abc4cc9945361502875e5 Mon Sep 17 00:00:00 2001 From: ANKUR DWIVEDI Date: Thu, 18 Jan 2024 09:39:10 +0530 Subject: [PATCH 04/17] added transformation parameter --- lib/active_storage/service/ik_file.rb | 4 ++++ lib/imagekitio/api_service/file.rb | 1 + lib/imagekitio/constants/file.rb | 2 +- test/imagekit/api_service/file_test.rb | 25 +++++++++++++++++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/lib/active_storage/service/ik_file.rb b/lib/active_storage/service/ik_file.rb index f855b5d..9b2b8f0 100644 --- a/lib/active_storage/service/ik_file.rb +++ b/lib/active_storage/service/ik_file.rb @@ -106,6 +106,10 @@ def updated_at def extension_status identifier['extensionStatus'] end + + def transformation + identifier['transformation'] + end end end end diff --git a/lib/imagekitio/api_service/file.rb b/lib/imagekitio/api_service/file.rb index f59d328..986cd21 100644 --- a/lib/imagekitio/api_service/file.rb +++ b/lib/imagekitio/api_service/file.rb @@ -36,6 +36,7 @@ def upload(file: nil, file_name: nil, **options) content_type = options.delete(:content_type) || '' options = format_to_json(options, :extensions, Array) options = format_to_json(options, :custom_metadata, Hash) + options = format_to_json(options, :transformation, Hash) options = validate_upload_options(options || {}) if options.is_a?(FalseClass) raise ArgumentError, "Invalid Upload option" diff --git a/lib/imagekitio/constants/file.rb b/lib/imagekitio/constants/file.rb index bea30fa..498e0d9 100644 --- a/lib/imagekitio/constants/file.rb +++ b/lib/imagekitio/constants/file.rb @@ -5,7 +5,7 @@ module File VALID_FILE_DETAIL_OPTIONS = ["fileID"] - VALID_UPLOAD_OPTIONS = %w[file file_name use_unique_file_name tags folder is_private_file custom_coordinates response_fields extensions webhook_url overwrite_file overwrite_AI_tags overwrite_custom_metadata custom_metadata mime overwrite_tags content_type ] + VALID_UPLOAD_OPTIONS = %w[file file_name use_unique_file_name tags folder is_private_file custom_coordinates response_fields extensions webhook_url overwrite_file overwrite_AI_tags overwrite_custom_metadata custom_metadata mime overwrite_tags content_type transformation ] end end end diff --git a/test/imagekit/api_service/file_test.rb b/test/imagekit/api_service/file_test.rb index 563ac73..f70f261 100644 --- a/test/imagekit/api_service/file_test.rb +++ b/test/imagekit/api_service/file_test.rb @@ -228,6 +228,31 @@ expect(@ac[:payload][:fileName]).to eq("fake_name") expect(upload[:status_code]).to eq(401) end + + it "test_upload_with_valid_expected_success_with_transformation" do + request_obj = double + allow(ImageKitIo::Request) + .to receive(:new) + .with(private_key, public_key, url_endpoint) + .and_return(request_obj) + + allow(request_obj) + .to receive(:create_headers) + .and_return({}) + @ac={} + allow(request_obj) + .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} + .and_return({status_code: 200}) + + SUT = file_api_service.new(request_obj) + + upload = SUT.upload(file: "./fake_file.jpg", file_name: "my_file_name", transformation: { pre: 'l-text,i-Imagekit,fs-50,l-end', post: [{type: 'transformation', value: 'b-10'}]}) + + expect(@ac[:payload].to_json).to eq("{\"multipart\":true,\"file\":\"./fake_file.jpg\",\"fileName\":\"my_file_name\",\"transformation\":"{\"pre\":\"l-text,i-Imagekit,fs-50,l-end\",\"post\":[{\"type\":\"transformation\",\"value\":\"w-100\"}]}"}") + + expect(upload[:status_code]).to eq(200) + + end end describe 'FileListTest' do From 32d23a0d554135489426652388b253d58fd3b0e8 Mon Sep 17 00:00:00 2001 From: ANKUR DWIVEDI Date: Thu, 18 Jan 2024 09:41:55 +0530 Subject: [PATCH 05/17] added transformation parameter --- test/imagekit/api_service/file_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/imagekit/api_service/file_test.rb b/test/imagekit/api_service/file_test.rb index f70f261..b792591 100644 --- a/test/imagekit/api_service/file_test.rb +++ b/test/imagekit/api_service/file_test.rb @@ -246,7 +246,7 @@ SUT = file_api_service.new(request_obj) - upload = SUT.upload(file: "./fake_file.jpg", file_name: "my_file_name", transformation: { pre: 'l-text,i-Imagekit,fs-50,l-end', post: [{type: 'transformation', value: 'b-10'}]}) + upload = SUT.upload(file: "./fake_file.jpg", file_name: "my_file_name", transformation: { pre: 'l-text,i-Imagekit,fs-50,l-end', post: [{type: 'transformation', value: 'w-100'}]}) expect(@ac[:payload].to_json).to eq("{\"multipart\":true,\"file\":\"./fake_file.jpg\",\"fileName\":\"my_file_name\",\"transformation\":"{\"pre\":\"l-text,i-Imagekit,fs-50,l-end\",\"post\":[{\"type\":\"transformation\",\"value\":\"w-100\"}]}"}") From 221dc2138dc9515cf6d257d53cf891314d790971 Mon Sep 17 00:00:00 2001 From: ANKUR DWIVEDI Date: Thu, 18 Jan 2024 09:46:19 +0530 Subject: [PATCH 06/17] added transformation parameter --- test/imagekit/api_service/file_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/imagekit/api_service/file_test.rb b/test/imagekit/api_service/file_test.rb index b792591..3c45372 100644 --- a/test/imagekit/api_service/file_test.rb +++ b/test/imagekit/api_service/file_test.rb @@ -248,7 +248,7 @@ upload = SUT.upload(file: "./fake_file.jpg", file_name: "my_file_name", transformation: { pre: 'l-text,i-Imagekit,fs-50,l-end', post: [{type: 'transformation', value: 'w-100'}]}) - expect(@ac[:payload].to_json).to eq("{\"multipart\":true,\"file\":\"./fake_file.jpg\",\"fileName\":\"my_file_name\",\"transformation\":"{\"pre\":\"l-text,i-Imagekit,fs-50,l-end\",\"post\":[{\"type\":\"transformation\",\"value\":\"w-100\"}]}"}") + expect(@ac[:payload]['transformation'].to_json).to eq("{\"pre\":\"l-text,i-Imagekit,fs-50,l-end\",\"post\":[{\"type\":\"transformation\",\"value\":\"w-100\"}]}") expect(upload[:status_code]).to eq(200) From cfe07fbc2f3f45a2eb15f6f8821ee88053bada15 Mon Sep 17 00:00:00 2001 From: ANKUR DWIVEDI Date: Thu, 18 Jan 2024 09:49:11 +0530 Subject: [PATCH 07/17] added transformation parameter --- test/imagekit/api_service/file_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/imagekit/api_service/file_test.rb b/test/imagekit/api_service/file_test.rb index 3c45372..a2aa8cf 100644 --- a/test/imagekit/api_service/file_test.rb +++ b/test/imagekit/api_service/file_test.rb @@ -248,7 +248,7 @@ upload = SUT.upload(file: "./fake_file.jpg", file_name: "my_file_name", transformation: { pre: 'l-text,i-Imagekit,fs-50,l-end', post: [{type: 'transformation', value: 'w-100'}]}) - expect(@ac[:payload]['transformation'].to_json).to eq("{\"pre\":\"l-text,i-Imagekit,fs-50,l-end\",\"post\":[{\"type\":\"transformation\",\"value\":\"w-100\"}]}") + expect(@ac[:payload]['transformation']).to eq("{\"pre\":\"l-text,i-Imagekit,fs-50,l-end\",\"post\":[{\"type\":\"transformation\",\"value\":\"w-100\"}]}") expect(upload[:status_code]).to eq(200) From 8a68b8ef5196e070d00856b83dc3077254b2e6bb Mon Sep 17 00:00:00 2001 From: ANKUR DWIVEDI Date: Thu, 18 Jan 2024 10:15:15 +0530 Subject: [PATCH 08/17] removed old overlay parameters --- .../constants/supported_transformation.rb | 27 ------------------ test/imagekit/url_test.rb | 28 +------------------ 2 files changed, 1 insertion(+), 54 deletions(-) diff --git a/lib/imagekitio/constants/supported_transformation.rb b/lib/imagekitio/constants/supported_transformation.rb index 864cad9..c8158b6 100644 --- a/lib/imagekitio/constants/supported_transformation.rb +++ b/lib/imagekitio/constants/supported_transformation.rb @@ -18,33 +18,6 @@ module SupportedTransformation 'rotation': "rt", 'blur': "bl", 'named': "n", - 'overlay_image': "oi", - 'overlay_image_trim': "oit", - 'overlay_image_cropping': "oic", - 'overlay_image_quality': "oiq", - 'overlay_image_DPR': "oidpr", - 'overlay_image_border': "oib", - 'overlay_image_background': "oibg", - 'overlay_image_aspect_ratio': "oiar", - 'overlay_x': "ox", - 'overlay_y': "oy", - 'overlay_focus': "ofo", - 'overlay_height': "oh", - 'overlay_width': "ow", - 'overlay_text': "ot", - 'overlay_text_font_size': "ots", - 'overlay_text_font_family': "otf", - 'overlay_text_encoded': "ote", - 'overlay_text_color': "otc", - 'overlay_text_width': "otw", - 'overlay_text_background': "otbg", - 'overlay_text_padding': "otp", - 'overlay_text_inner_alignment': "otia", - 'overlay_text_transparency': "oa", - 'overlay_alpha': "oa", - 'overlay_radius': "or", - 'overlay_text_typography': "ott", - 'overlay_background': "obg", 'progressive': "pr", 'lossless': "lo", 'trim': "t", diff --git a/test/imagekit/url_test.rb b/test/imagekit/url_test.rb index e0163ba..88b6051 100644 --- a/test/imagekit/url_test.rb +++ b/test/imagekit/url_test.rb @@ -158,32 +158,6 @@ rotation: 90, blur: 10, named: "some_name", - overlay_x: 35, - overlay_y: 35, - overlay_focus: "bottom", - overlay_height: 20, - overlay_width: 20, - overlay_image: "/folder/file.jpg", - overlay_image_trim: false, - overlay_image_aspect_ratio: "4:3", - overlay_image_background: "0F0F0F", - overlay_image_border: "10_0F0F0F", - overlay_image_DPR: 2, - overlay_image_quality: 50, - overlay_image_cropping: "force", - overlay_text: "two words", - overlay_text_font_size: 20, - overlay_text_font_family: "Open Sans", - overlay_text_color: "00FFFF", - overlay_text_transparency: 5, - overlay_text_typography: "b", - overlay_background: "00AAFF55", - overlay_text_encoded: "b3ZlcmxheSBtYWRlIGVhc3k%3D", - overlay_text_width: 50, - overlay_text_background: "00AAFF55", - overlay_text_padding: 40, - overlay_text_inner_alignment: "left", - overlay_radius: 10, progressive: true, lossless: true, trim: 5, @@ -202,7 +176,7 @@ },] } url = url_obj.generate_url(options) - expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400,ar-4-3,q-40,c-force,cm-extract,fo-left,f-jpeg,r-50,bg-A94D34,b-5-A94D34,rt-90,bl-10,n-some_name,ox-35,oy-35,ofo-bottom,oh-20,ow-20,oi-folder@@file.jpg,oit-false,oiar-4:3,oibg-0F0F0F,oib-10_0F0F0F,oidpr-2,oiq-50,oic-force,ot-two words,ots-20,otf-Open Sans,otc-00FFFF,oa-5,ott-b,obg-00AAFF55,ote-b3ZlcmxheSBtYWRlIGVhc3k%3D,otw-50,otbg-00AAFF55,otp-40,otia-left,or-10,pr-true,lo-true,t-5,md-true,cp-true,di-folder@@file.jpg,dpr-3,e-sharpen-10,e-usm-2-2-0.8-0.024,e-contrast-true,e-grayscale-true,e-shadow-bl-15_st-40_x-10_y-N5,e-gradient-from-red_to-white,orig-true,w-200,h-200/default-image.jpg") + expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400,ar-4-3,q-40,c-force,cm-extract,fo-left,f-jpeg,r-50,bg-A94D34,b-5-A94D34,rt-90,bl-10,n-some_name,pr-true,lo-true,t-5,md-true,cp-true,di-folder@@file.jpg,dpr-3,e-sharpen-10,e-usm-2-2-0.8-0.024,e-contrast-true,e-grayscale-true,e-shadow-bl-15_st-40_x-10_y-N5,e-gradient-from-red_to-white,orig-true,w-200,h-200/default-image.jpg") end it "test_generate_url_with_chained_transformation" do From 4deadda63976a10b3b03b58830c50005a8db69bb Mon Sep 17 00:00:00 2001 From: ANKUR DWIVEDI Date: Thu, 18 Jan 2024 10:19:51 +0530 Subject: [PATCH 09/17] reverted --- .../constants/supported_transformation.rb | 27 ++++++++++++++++++ test/imagekit/url_test.rb | 28 ++++++++++++++++++- 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/lib/imagekitio/constants/supported_transformation.rb b/lib/imagekitio/constants/supported_transformation.rb index c8158b6..864cad9 100644 --- a/lib/imagekitio/constants/supported_transformation.rb +++ b/lib/imagekitio/constants/supported_transformation.rb @@ -18,6 +18,33 @@ module SupportedTransformation 'rotation': "rt", 'blur': "bl", 'named': "n", + 'overlay_image': "oi", + 'overlay_image_trim': "oit", + 'overlay_image_cropping': "oic", + 'overlay_image_quality': "oiq", + 'overlay_image_DPR': "oidpr", + 'overlay_image_border': "oib", + 'overlay_image_background': "oibg", + 'overlay_image_aspect_ratio': "oiar", + 'overlay_x': "ox", + 'overlay_y': "oy", + 'overlay_focus': "ofo", + 'overlay_height': "oh", + 'overlay_width': "ow", + 'overlay_text': "ot", + 'overlay_text_font_size': "ots", + 'overlay_text_font_family': "otf", + 'overlay_text_encoded': "ote", + 'overlay_text_color': "otc", + 'overlay_text_width': "otw", + 'overlay_text_background': "otbg", + 'overlay_text_padding': "otp", + 'overlay_text_inner_alignment': "otia", + 'overlay_text_transparency': "oa", + 'overlay_alpha': "oa", + 'overlay_radius': "or", + 'overlay_text_typography': "ott", + 'overlay_background': "obg", 'progressive': "pr", 'lossless': "lo", 'trim': "t", diff --git a/test/imagekit/url_test.rb b/test/imagekit/url_test.rb index 88b6051..e0163ba 100644 --- a/test/imagekit/url_test.rb +++ b/test/imagekit/url_test.rb @@ -158,6 +158,32 @@ rotation: 90, blur: 10, named: "some_name", + overlay_x: 35, + overlay_y: 35, + overlay_focus: "bottom", + overlay_height: 20, + overlay_width: 20, + overlay_image: "/folder/file.jpg", + overlay_image_trim: false, + overlay_image_aspect_ratio: "4:3", + overlay_image_background: "0F0F0F", + overlay_image_border: "10_0F0F0F", + overlay_image_DPR: 2, + overlay_image_quality: 50, + overlay_image_cropping: "force", + overlay_text: "two words", + overlay_text_font_size: 20, + overlay_text_font_family: "Open Sans", + overlay_text_color: "00FFFF", + overlay_text_transparency: 5, + overlay_text_typography: "b", + overlay_background: "00AAFF55", + overlay_text_encoded: "b3ZlcmxheSBtYWRlIGVhc3k%3D", + overlay_text_width: 50, + overlay_text_background: "00AAFF55", + overlay_text_padding: 40, + overlay_text_inner_alignment: "left", + overlay_radius: 10, progressive: true, lossless: true, trim: 5, @@ -176,7 +202,7 @@ },] } url = url_obj.generate_url(options) - expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400,ar-4-3,q-40,c-force,cm-extract,fo-left,f-jpeg,r-50,bg-A94D34,b-5-A94D34,rt-90,bl-10,n-some_name,pr-true,lo-true,t-5,md-true,cp-true,di-folder@@file.jpg,dpr-3,e-sharpen-10,e-usm-2-2-0.8-0.024,e-contrast-true,e-grayscale-true,e-shadow-bl-15_st-40_x-10_y-N5,e-gradient-from-red_to-white,orig-true,w-200,h-200/default-image.jpg") + expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400,ar-4-3,q-40,c-force,cm-extract,fo-left,f-jpeg,r-50,bg-A94D34,b-5-A94D34,rt-90,bl-10,n-some_name,ox-35,oy-35,ofo-bottom,oh-20,ow-20,oi-folder@@file.jpg,oit-false,oiar-4:3,oibg-0F0F0F,oib-10_0F0F0F,oidpr-2,oiq-50,oic-force,ot-two words,ots-20,otf-Open Sans,otc-00FFFF,oa-5,ott-b,obg-00AAFF55,ote-b3ZlcmxheSBtYWRlIGVhc3k%3D,otw-50,otbg-00AAFF55,otp-40,otia-left,or-10,pr-true,lo-true,t-5,md-true,cp-true,di-folder@@file.jpg,dpr-3,e-sharpen-10,e-usm-2-2-0.8-0.024,e-contrast-true,e-grayscale-true,e-shadow-bl-15_st-40_x-10_y-N5,e-gradient-from-red_to-white,orig-true,w-200,h-200/default-image.jpg") end it "test_generate_url_with_chained_transformation" do From bbc152570e424eeaf2b44e130331e401084104fd Mon Sep 17 00:00:00 2001 From: ANKUR DWIVEDI Date: Thu, 18 Jan 2024 10:26:29 +0530 Subject: [PATCH 10/17] removed old overlay parameters --- .../constants/supported_transformation.rb | 27 ------------------ test/imagekit/url_test.rb | 28 +------------------ 2 files changed, 1 insertion(+), 54 deletions(-) diff --git a/lib/imagekitio/constants/supported_transformation.rb b/lib/imagekitio/constants/supported_transformation.rb index 864cad9..c8158b6 100644 --- a/lib/imagekitio/constants/supported_transformation.rb +++ b/lib/imagekitio/constants/supported_transformation.rb @@ -18,33 +18,6 @@ module SupportedTransformation 'rotation': "rt", 'blur': "bl", 'named': "n", - 'overlay_image': "oi", - 'overlay_image_trim': "oit", - 'overlay_image_cropping': "oic", - 'overlay_image_quality': "oiq", - 'overlay_image_DPR': "oidpr", - 'overlay_image_border': "oib", - 'overlay_image_background': "oibg", - 'overlay_image_aspect_ratio': "oiar", - 'overlay_x': "ox", - 'overlay_y': "oy", - 'overlay_focus': "ofo", - 'overlay_height': "oh", - 'overlay_width': "ow", - 'overlay_text': "ot", - 'overlay_text_font_size': "ots", - 'overlay_text_font_family': "otf", - 'overlay_text_encoded': "ote", - 'overlay_text_color': "otc", - 'overlay_text_width': "otw", - 'overlay_text_background': "otbg", - 'overlay_text_padding': "otp", - 'overlay_text_inner_alignment': "otia", - 'overlay_text_transparency': "oa", - 'overlay_alpha': "oa", - 'overlay_radius': "or", - 'overlay_text_typography': "ott", - 'overlay_background': "obg", 'progressive': "pr", 'lossless': "lo", 'trim': "t", diff --git a/test/imagekit/url_test.rb b/test/imagekit/url_test.rb index e0163ba..88b6051 100644 --- a/test/imagekit/url_test.rb +++ b/test/imagekit/url_test.rb @@ -158,32 +158,6 @@ rotation: 90, blur: 10, named: "some_name", - overlay_x: 35, - overlay_y: 35, - overlay_focus: "bottom", - overlay_height: 20, - overlay_width: 20, - overlay_image: "/folder/file.jpg", - overlay_image_trim: false, - overlay_image_aspect_ratio: "4:3", - overlay_image_background: "0F0F0F", - overlay_image_border: "10_0F0F0F", - overlay_image_DPR: 2, - overlay_image_quality: 50, - overlay_image_cropping: "force", - overlay_text: "two words", - overlay_text_font_size: 20, - overlay_text_font_family: "Open Sans", - overlay_text_color: "00FFFF", - overlay_text_transparency: 5, - overlay_text_typography: "b", - overlay_background: "00AAFF55", - overlay_text_encoded: "b3ZlcmxheSBtYWRlIGVhc3k%3D", - overlay_text_width: 50, - overlay_text_background: "00AAFF55", - overlay_text_padding: 40, - overlay_text_inner_alignment: "left", - overlay_radius: 10, progressive: true, lossless: true, trim: 5, @@ -202,7 +176,7 @@ },] } url = url_obj.generate_url(options) - expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400,ar-4-3,q-40,c-force,cm-extract,fo-left,f-jpeg,r-50,bg-A94D34,b-5-A94D34,rt-90,bl-10,n-some_name,ox-35,oy-35,ofo-bottom,oh-20,ow-20,oi-folder@@file.jpg,oit-false,oiar-4:3,oibg-0F0F0F,oib-10_0F0F0F,oidpr-2,oiq-50,oic-force,ot-two words,ots-20,otf-Open Sans,otc-00FFFF,oa-5,ott-b,obg-00AAFF55,ote-b3ZlcmxheSBtYWRlIGVhc3k%3D,otw-50,otbg-00AAFF55,otp-40,otia-left,or-10,pr-true,lo-true,t-5,md-true,cp-true,di-folder@@file.jpg,dpr-3,e-sharpen-10,e-usm-2-2-0.8-0.024,e-contrast-true,e-grayscale-true,e-shadow-bl-15_st-40_x-10_y-N5,e-gradient-from-red_to-white,orig-true,w-200,h-200/default-image.jpg") + expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400,ar-4-3,q-40,c-force,cm-extract,fo-left,f-jpeg,r-50,bg-A94D34,b-5-A94D34,rt-90,bl-10,n-some_name,pr-true,lo-true,t-5,md-true,cp-true,di-folder@@file.jpg,dpr-3,e-sharpen-10,e-usm-2-2-0.8-0.024,e-contrast-true,e-grayscale-true,e-shadow-bl-15_st-40_x-10_y-N5,e-gradient-from-red_to-white,orig-true,w-200,h-200/default-image.jpg") end it "test_generate_url_with_chained_transformation" do From 99685a95c183ead7b2ce7aa6c9ec32ebf1a88c9e Mon Sep 17 00:00:00 2001 From: ANKUR DWIVEDI Date: Thu, 18 Jan 2024 17:29:49 +0530 Subject: [PATCH 11/17] updated readme --- README.md | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 62976b0..1437d68 100644 --- a/README.md +++ b/README.md @@ -352,6 +352,29 @@ image_url = imagekit.url({ https://ik.imagekit.io/your_imagekit_id/tr:h-300,w-400,l-image,i-ik_canvas,bg-FF0000,w-300,h-100,l-end/img/sample-video.mp4 ``` +**5. Arithmetic expressions In transformations** + +ImageKit allows use of [arithmetic expressions](https://docs.imagekit.io/features/arithmetic-expressions-in-transformations) in certain dimension and position-related parameters, making media transformations more flexible and dynamic. + +For example: + +```ruby +image_url = imagekit.url({ + path: "/default-image.jpg", + url_endpoint: "https://ik.imagekit.io/your_imagekit_id/endpoint/", + transformation: [{ + width: "iw_div_4", + height: "ih_div_2", + border: "cw_mul_0.05_yellow" + }] +}); +``` + +**Sample Result URL** +``` +https://ik.imagekit.io/your_imagekit_id/default-image.jpg?tr=w-iw_div_4,h-ih_div_2,b-cw_mul_0.05_yellow +``` + **List of transformations** The complete list of transformations supported and their usage in ImageKit can be found [here](https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations). The SDK gives a name to each transformation parameter, making the code simpler, making the code simpler, and readable. @@ -364,10 +387,10 @@ If you want to generate transformations in your application and add them to the |-------------------------------|-------------------------| | height | h | | width | w | -| aspectRatio | ar | +| aspect_ratio | ar | | quality | q | | crop | c | -| cropMode | cm | +| crop_mode | cm | | x | x | | y | y | | focus | fo | @@ -382,13 +405,15 @@ If you want to generate transformations in your application and add them to the | lossless | lo | | trim | t | | metadata | md | -| colorProfile | cp | -| defaultImage | di | +| color_profile | cp | +| default_image | di | | dpr | dpr | -| effectSharpen | e-sharpen | -| effectUSM | e-usm | -| effectContrast | e-contrast | -| effectGray | e-grayscale | +| effect_sharpen | e-sharpen | +| effect_usm | e-usm | +| effect_contrast | e-contrast | +| effect_gray | e-grayscale | +| effect_shadow | e-shadow | +| effect_gradient | e-gradient | | original | orig | | raw | `replaced by the parameter value` | From f8209dd8a4cf083d097d1be082ec776ba5d45729 Mon Sep 17 00:00:00 2001 From: ANKUR DWIVEDI Date: Wed, 24 Jan 2024 06:46:37 +0530 Subject: [PATCH 12/17] version bump --- README.md | 2 +- lib/imagekitio/sdk/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1437d68..6e62df4 100644 --- a/README.md +++ b/README.md @@ -352,7 +352,7 @@ image_url = imagekit.url({ https://ik.imagekit.io/your_imagekit_id/tr:h-300,w-400,l-image,i-ik_canvas,bg-FF0000,w-300,h-100,l-end/img/sample-video.mp4 ``` -**5. Arithmetic expressions In transformations** +**5. Arithmetic expressions in transformations** ImageKit allows use of [arithmetic expressions](https://docs.imagekit.io/features/arithmetic-expressions-in-transformations) in certain dimension and position-related parameters, making media transformations more flexible and dynamic. diff --git a/lib/imagekitio/sdk/version.rb b/lib/imagekitio/sdk/version.rb index baf95f8..c188581 100644 --- a/lib/imagekitio/sdk/version.rb +++ b/lib/imagekitio/sdk/version.rb @@ -1,5 +1,5 @@ module ImageKitIo module Sdk - VERSION = '2.3.1' + VERSION = '3.0.0' end end From 686e8a9663e01064f4d96ba9af708b6b52cdf867 Mon Sep 17 00:00:00 2001 From: ANKUR DWIVEDI Date: Thu, 25 Jan 2024 09:50:01 +0530 Subject: [PATCH 13/17] update readme --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 6e62df4..1867bec 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ Ruby on Rails gem for [ImageKit](https://imagekit.io/) implements the new APIs a ImageKit is complete media storage, optimization, and transformation solution that comes with an [image and video CDN](https://imagekit.io/features/imagekit-infrastructure). It can be integrated with your existing infrastructure - storage like AWS S3, web servers, your CDN, and custom domain names, allowing you to deliver optimized images in minutes with minimal code changes. Table of contents - + * [Changelog](#changelog) * [Installation](#installation) * [Initialization](#initialization) - [CarrierWave](#carrierwave) @@ -30,6 +31,13 @@ Table of contents - # Quick start guide Get started with [official quick start guide](https://docs.imagekit.io/getting-started/quickstart-guides/ruby-on-rails) for integrating ImageKit in Ruby on Rails. +## Changelog +### SDK Version 3.0.0 +#### Breaking changes +**1. Overlay syntax update** +* In version 3.0.0, we've removed the old overlay syntax parameters 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. + ## Installation Add `imagekitio` dependency to your application's Gemfile: From b80949a0cd92023d56c9aecaa0f4d53d9f614078 Mon Sep 17 00:00:00 2001 From: ANKUR DWIVEDI Date: Thu, 25 Jan 2024 09:58:25 +0530 Subject: [PATCH 14/17] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1867bec..0f708a8 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Get started with [official quick start guide](https://docs.imagekit.io/getting-s ### SDK Version 3.0.0 #### Breaking changes **1. Overlay syntax update** -* In version 3.0.0, we've removed the old overlay syntax parameters 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. +* In version 3.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. ## Installation From 3f37e42ff45b129b55b5bd9274f09aa19c36d513 Mon Sep 17 00:00:00 2001 From: ANKUR DWIVEDI Date: Thu, 25 Jan 2024 10:57:20 +0530 Subject: [PATCH 15/17] update readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0f708a8..f6b72bf 100644 --- a/README.md +++ b/README.md @@ -35,8 +35,8 @@ Get started with [official quick start guide](https://docs.imagekit.io/getting-s ### SDK Version 3.0.0 #### Breaking changes **1. Overlay syntax update** -* In version 3.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. +* In version 3.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. ## Installation From 0770be3d4726da69e60add8a312652d2a2e731ac Mon Sep 17 00:00:00 2001 From: ANKUR DWIVEDI Date: Thu, 25 Jan 2024 13:01:22 +0530 Subject: [PATCH 16/17] updated ci --- .github/workflows/gempush.yml | 6 +++--- .github/workflows/test.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/gempush.yml b/.github/workflows/gempush.yml index 57d06c9..a633516 100644 --- a/.github/workflows/gempush.yml +++ b/.github/workflows/gempush.yml @@ -10,14 +10,14 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up Ruby 3.0 + - name: Set up Ruby 2.6 uses: ruby/setup-ruby@v1.126.0 with: - ruby-version: 3.0.0 + ruby-version: 2.6.5 - name: Run Test Cases run: | - gem install bundler + gem install bundler -v 2.4.22 bundle install --jobs 4 --retry 3 bundle exec rake diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9fbf4d1..1eefd47 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,13 +9,13 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up Ruby 3.0 + - name: Set up Ruby 2.6 uses: ruby/setup-ruby@v1.126.0 with: - ruby-version: 3.0.0 + ruby-version: 2.6.5 - name: Build and test with Rake run: | - gem install bundler + gem install bundler -v 2.4.22 bundle install --jobs 4 --retry 3 bundle exec rake # - name: Upload code coverage reports to codecov From 8907702448fab9bf6c7f76ccf79d42cdba497dc6 Mon Sep 17 00:00:00 2001 From: ANKUR DWIVEDI Date: Thu, 25 Jan 2024 13:05:56 +0530 Subject: [PATCH 17/17] updated ci --- .github/workflows/gempush.yml | 2 +- .github/workflows/test.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/gempush.yml b/.github/workflows/gempush.yml index a633516..cfdff3a 100644 --- a/.github/workflows/gempush.yml +++ b/.github/workflows/gempush.yml @@ -14,7 +14,7 @@ jobs: uses: ruby/setup-ruby@v1.126.0 with: ruby-version: 2.6.5 - + bundler: 2.4.22 - name: Run Test Cases run: | gem install bundler -v 2.4.22 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1eefd47..8c68db1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,6 +13,7 @@ jobs: uses: ruby/setup-ruby@v1.126.0 with: ruby-version: 2.6.5 + bundler: 2.4.22 - name: Build and test with Rake run: | gem install bundler -v 2.4.22