imagekitio 2.3.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b7426d823c34ead157150f2413efda3f1f8fd12b0d53a400cd530f4b7f5f9819
4
- data.tar.gz: 646a956c5bbf90bc438b4ca594644f76004fa5363a2cd955947ad7e5547789ab
3
+ metadata.gz: f841345e7c60108adfa1daec086a76fdd194202415904c18c61c14719424b224
4
+ data.tar.gz: 658901c8ad3a60f41bd1b1740fb188fd188edc569e0822947ede150916b567b9
5
5
  SHA512:
6
- metadata.gz: 73453ebcb67186cecc40163a8c8033f2823fe001c550785ee806913d4ef7cda9e2258a22f3af24f6655276604f4509c55b9f5ec627acadb8f899138be5835735
7
- data.tar.gz: d59c94eca505d2b44cb02846e46a9a866ce2acfa475599b95bc54ab3a51bcc762bd3c35222b2b8c33928a363e6f78db44fd70e8f82406d5884c93647d2b3d475
6
+ metadata.gz: cf58e04df78c584e13b049089eb2777aab6c232c4d99c0c0e6063f05f733895eb0eaf8625bfe4cc8da919c1231c08be2d4733cb30290cf9b7c422578c2021612
7
+ data.tar.gz: e037b5e7739d131f7496cb13944ee5eb0f2face165a22ce625b2458d11e58f3cd1d2cc4bf06fb5eb3b2e43e4c7cfc2687476695e8ff10f74a5527484ed9db500
data/README.md CHANGED
@@ -13,6 +13,7 @@ Ruby on Rails gem for [ImageKit](https://imagekit.io/) implements the new APIs a
13
13
  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.
14
14
 
15
15
  Table of contents -
16
+ * [Changelog](#changelog)
16
17
  * [Installation](#installation)
17
18
  * [Initialization](#initialization)
18
19
  - [CarrierWave](#carrierwave)
@@ -28,7 +29,14 @@ Table of contents -
28
29
 
29
30
 
30
31
  # Quick start guide
31
- 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.
32
+ Get started with [official quick start guide](https://docs.imagekit.io/getting-started/quickstart-guides/ruby-guides) for integrating ImageKit in Ruby on Rails.
33
+
34
+ ## Changelog
35
+ ### SDK Version 3.0.0
36
+ #### Breaking changes
37
+ **1. Overlay syntax update**
38
+ * 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.
39
+ * You can migrate to the new layers syntax using the `raw` transformation parameter.
32
40
 
33
41
  ## Installation
34
42
 
@@ -282,6 +290,99 @@ image_url = imagekit.url({
282
290
  https://ik.imagekit.io/your_imagekit_id/tr:h-300,w-400/default-image.jpg?v=123&ik-t=1567358667&ik-s=f2c7cdacbe7707b71a83d49cf1c6110e3d701054
283
291
  ```
284
292
 
293
+ **4. Adding overlays**
294
+
295
+ ImageKit.io enables you to apply overlays to [images](https://docs.imagekit.io/features/image-transformations/overlay-using-layers) and [videos](https://docs.imagekit.io/features/video-transformation/overlay) using the raw parameter with the concept of [layers](https://docs.imagekit.io/features/image-transformations/overlay-using-layers#layers). The raw parameter facilitates incorporating transformations directly in the URL. A layer is a distinct type of transformation that allows you to define an asset to serve as an overlay, along with its positioning and additional transformations.
296
+
297
+ **Text as overlays**
298
+
299
+ You can add any text string over a base video or image using a text layer (l-text).
300
+
301
+ For example:
302
+
303
+ ```ruby
304
+ image_url = imagekit.url({
305
+ path: "/default-image",
306
+ url_endpoint: "https://ik.imagekit.io/your_imagekit_id/endpoint/",
307
+ transformation: [{
308
+ height: "300",
309
+ width: "400",
310
+ raw: "l-text,i-Imagekit,fs-50,l-end"
311
+ }],
312
+ })
313
+ ```
314
+ **Sample Result URL**
315
+ ```
316
+ https://ik.imagekit.io/your_imagekit_id/tr:h-300,w-400,l-text,i-Imagekit,fs-50,l-end/default-image.jpg
317
+ ```
318
+
319
+ **Image as overlays**
320
+
321
+ You can add an image over a base video or image using an image layer (l-image).
322
+
323
+ For example:
324
+
325
+ ```ruby
326
+ image_url = imagekit.url({
327
+ path: "/default-image",
328
+ url_endpoint: "https://ik.imagekit.io/your_imagekit_id/endpoint/",
329
+ transformation: [{
330
+ height: "300",
331
+ width: "400",
332
+ raw: "l-image,i-default-image.jpg,w-100,b-10_CDDC39,l-end"
333
+ }],
334
+ })
335
+ ```
336
+ **Sample Result URL**
337
+ ```
338
+ https://ik.imagekit.io/your_imagekit_id/tr:h-300,w-400,l-image,i-default-image.jpg,w-100,b-10_CDDC39,l-end/default-image.jpg
339
+ ```
340
+
341
+ **Solid color blocks as overlays**
342
+
343
+ You can add solid color blocks over a base video or image using an image layer (l-image).
344
+
345
+ For example:
346
+
347
+ ```ruby
348
+ image_url = imagekit.url({
349
+ path: "/img/sample-video",
350
+ url_endpoint: "https://ik.imagekit.io/your_imagekit_id/endpoint/",
351
+ transformation: [{
352
+ height: "300",
353
+ width: "400",
354
+ raw: "l-image,i-ik_canvas,bg-FF0000,w-300,h-100,l-end"
355
+ }],
356
+ })
357
+ ```
358
+ **Sample Result URL**
359
+ ```
360
+ 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
361
+ ```
362
+
363
+ **5. Arithmetic expressions in transformations**
364
+
365
+ 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.
366
+
367
+ For example:
368
+
369
+ ```ruby
370
+ image_url = imagekit.url({
371
+ path: "/default-image.jpg",
372
+ url_endpoint: "https://ik.imagekit.io/your_imagekit_id/endpoint/",
373
+ transformation: [{
374
+ width: "iw_div_4",
375
+ height: "ih_div_2",
376
+ border: "cw_mul_0.05_yellow"
377
+ }]
378
+ });
379
+ ```
380
+
381
+ **Sample Result URL**
382
+ ```
383
+ 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
384
+ ```
385
+
285
386
  **List of transformations**
286
387
 
287
388
  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.
@@ -294,10 +395,10 @@ If you want to generate transformations in your application and add them to the
294
395
  |-------------------------------|-------------------------|
295
396
  | height | h |
296
397
  | width | w |
297
- | aspectRatio | ar |
398
+ | aspect_ratio | ar |
298
399
  | quality | q |
299
400
  | crop | c |
300
- | cropMode | cm |
401
+ | crop_mode | cm |
301
402
  | x | x |
302
403
  | y | y |
303
404
  | focus | fo |
@@ -308,45 +409,19 @@ If you want to generate transformations in your application and add them to the
308
409
  | rotation | rt |
309
410
  | blur | bl |
310
411
  | named | n |
311
- | overlayX | ox |
312
- | overlayY | oy |
313
- | overlayFocus | ofo |
314
- | overlayHeight | oh |
315
- | overlayWidth | ow |
316
- | overlayImage | oi |
317
- | overlayImageTrim | oit |
318
- | overlayImageAspectRatio | oiar |
319
- | overlayImageBackground | oibg |
320
- | overlayImageBorder | oib |
321
- | overlayImageDPR | oidpr |
322
- | overlayImageQuality | oiq |
323
- | overlayImageCropping | oic |
324
- | overlayImageTrim | oit |
325
- | overlayText | ot |
326
- | overlayTextFontSize | ots |
327
- | overlayTextFontFamily | otf |
328
- | overlayTextColor | otc |
329
- | overlayTextTransparency | oa |
330
- | overlayAlpha | oa |
331
- | overlayTextTypography | ott |
332
- | overlayBackground | obg |
333
- | overlayTextEncoded | ote |
334
- | overlayTextWidth | otw |
335
- | overlayTextBackground | otbg |
336
- | overlayTextPadding | otp |
337
- | overlayTextInnerAlignment | otia |
338
- | overlayRadius | or |
339
412
  | progressive | pr |
340
413
  | lossless | lo |
341
414
  | trim | t |
342
415
  | metadata | md |
343
- | colorProfile | cp |
344
- | defaultImage | di |
416
+ | color_profile | cp |
417
+ | default_image | di |
345
418
  | dpr | dpr |
346
- | effectSharpen | e-sharpen |
347
- | effectUSM | e-usm |
348
- | effectContrast | e-contrast |
349
- | effectGray | e-grayscale |
419
+ | effect_sharpen | e-sharpen |
420
+ | effect_usm | e-usm |
421
+ | effect_contrast | e-contrast |
422
+ | effect_gray | e-grayscale |
423
+ | effect_shadow | e-shadow |
424
+ | effect_gradient | e-gradient |
350
425
  | original | orig |
351
426
  | raw | `replaced by the parameter value` |
352
427
 
@@ -368,7 +443,18 @@ imagekitio.upload_file(
368
443
  file_name: "my_file_name.jpg", # required
369
444
  response_fields: 'isPrivateFile, tags',
370
445
  tags: %w[abc def],
371
- use_unique_file_name: true
446
+ use_unique_file_name: true,
447
+ transformation: {
448
+ pre: 'l-text,i-Imagekit,fs-50,l-end',
449
+ post: [
450
+ {
451
+ type: 'transformation',
452
+ value: 'w-100'
453
+ }
454
+ ]
455
+ },
456
+ checks: "'request.folder' : '/'" # To run server side checks before uploading files. Notice the quotes around file.size and 1mb.
457
+ is_published: true
372
458
  )
373
459
 
374
460
  ```
@@ -395,6 +481,7 @@ imagekitio.list_files(
395
481
  )
396
482
  ```
397
483
  **Get File Details**
484
+
398
485
  Accepts the file ID and fetches the details as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/get-file-details)
399
486
 
400
487
  ```ruby
@@ -404,6 +491,7 @@ imagekitio.get_file_details(
404
491
  ```
405
492
 
406
493
  **Get File Metadata**
494
+
407
495
  Accepts the file ID and fetches the metadata as per the [API documentation here](https://docs.imagekit.io/api-reference/metadata-api/get-image-metadata-for-uploaded-media-files)
408
496
  ```ruby
409
497
  imagekit.get_file_metadata(
@@ -412,6 +500,7 @@ imagekit.get_file_metadata(
412
500
  ```
413
501
 
414
502
  **Get File Metadata from remote url**
503
+
415
504
  Accepts the remote file url and fetches the metadata as per the [API documentation here](https://docs.imagekit.io/api-reference/metadata-api/get-image-metadata-from-remote-url)
416
505
 
417
506
  ```ruby
@@ -421,6 +510,7 @@ imagekit.get_remote_file_url_metadata(
421
510
  ```
422
511
 
423
512
  **Update File Details**
513
+
424
514
  Update parameters associated with the file as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/update-file-details).
425
515
  The first argument to the `update_field_details` method is the file ID, and a second argument is an object with the
426
516
  parameters to be updated.
@@ -433,6 +523,21 @@ imagekitio.update_file_details(
433
523
  )
434
524
  ```
435
525
 
526
+
527
+ **Update publish status**
528
+
529
+ If `publish` is included in the update options, no other parameters are allowed. If any are present, an error will be returned: `Your request cannot contain any other parameters when publish is present`.
530
+
531
+ ```ruby
532
+ imagekitio.update_file_details(
533
+ file_id: '598821f949c0a938d57563bd',
534
+ publish:{
535
+ isPublished: true,
536
+ includeFileVersions: true
537
+ }
538
+ )
539
+ ```
540
+
436
541
  **Copy File**
437
542
 
438
543
  Copy file from one path to another path using the source file path and the destination path as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/copy-file)
@@ -106,6 +106,10 @@ module ImageKiIo
106
106
  def extension_status
107
107
  identifier['extensionStatus']
108
108
  end
109
+
110
+ def transformation
111
+ identifier['transformation']
112
+ end
109
113
  end
110
114
  end
111
115
  end
@@ -36,6 +36,7 @@ module ImageKitIo
36
36
  content_type = options.delete(:content_type) || ''
37
37
  options = format_to_json(options, :extensions, Array)
38
38
  options = format_to_json(options, :custom_metadata, Hash)
39
+ options = format_to_json(options, :transformation, Hash)
39
40
  options = validate_upload_options(options || {})
40
41
  if options.is_a?(FalseClass)
41
42
  raise ArgumentError, "Invalid Upload option"
@@ -5,7 +5,7 @@ module ImageKitIo
5
5
 
6
6
  VALID_FILE_DETAIL_OPTIONS = ["fileID"]
7
7
 
8
- 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 ]
8
+ 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 checks is_published]
9
9
  end
10
10
  end
11
11
  end
@@ -18,33 +18,6 @@ module ImageKitIo
18
18
  'rotation': "rt",
19
19
  'blur': "bl",
20
20
  'named': "n",
21
- 'overlay_image': "oi",
22
- 'overlay_image_trim': "oit",
23
- 'overlay_image_cropping': "oic",
24
- 'overlay_image_quality': "oiq",
25
- 'overlay_image_DPR': "oidpr",
26
- 'overlay_image_border': "oib",
27
- 'overlay_image_background': "oibg",
28
- 'overlay_image_aspect_ratio': "oiar",
29
- 'overlay_x': "ox",
30
- 'overlay_y': "oy",
31
- 'overlay_focus': "ofo",
32
- 'overlay_height': "oh",
33
- 'overlay_width': "ow",
34
- 'overlay_text': "ot",
35
- 'overlay_text_font_size': "ots",
36
- 'overlay_text_font_family': "otf",
37
- 'overlay_text_encoded': "ote",
38
- 'overlay_text_color': "otc",
39
- 'overlay_text_width': "otw",
40
- 'overlay_text_background': "otbg",
41
- 'overlay_text_padding': "otp",
42
- 'overlay_text_inner_alignment': "otia",
43
- 'overlay_text_transparency': "oa",
44
- 'overlay_alpha': "oa",
45
- 'overlay_radius': "or",
46
- 'overlay_text_typography': "ott",
47
- 'overlay_background': "obg",
48
21
  'progressive': "pr",
49
22
  'lossless': "lo",
50
23
  'trim': "t",
@@ -56,6 +29,8 @@ module ImageKitIo
56
29
  'effect_usm': "e-usm",
57
30
  'effect_contrast': "e-contrast",
58
31
  'effect_gray': "e-grayscale",
32
+ 'effect_shadow': "e-shadow",
33
+ 'effect_gradient': "e-gradient",
59
34
  'original': "orig",
60
35
  'raw': 'raw',
61
36
  }
@@ -1,5 +1,5 @@
1
1
  module ImageKitIo
2
2
  module Sdk
3
- VERSION = '2.3.0'
3
+ VERSION = '3.1.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imagekitio
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ImageKit.io team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-23 00:00:00.000000000 Z
11
+ date: 2024-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable