SDKs overview
ImageKit offers a range of Software Development Kits (SDKs) and libraries designed to facilitate integration with its media processing and delivery services. These SDKs are developed to streamline common operations such as generating optimized image URLs, performing real-time image transformations, managing media assets, and handling file uploads programmatically. The availability of SDKs for multiple programming languages and frontend frameworks aims to reduce development effort and accelerate the implementation of ImageKit features into diverse application architectures. For a comprehensive understanding of ImageKit's capabilities, developers can refer to the official ImageKit documentation.
The SDKs abstract the construction of complex image URLs, which often involve parameters for resizing, cropping, watermarking, and format conversion. By using an SDK, developers can specify desired transformations through method calls or configuration objects, allowing the SDK to assemble the correct URL structure. This approach helps minimize errors and ensures adherence to ImageKit's URL syntax. Beyond URL generation, some SDKs also provide utilities for direct interaction with the ImageKit API for tasks like uploading files or managing existing media assets.
Official SDKs by language
ImageKit provides official SDKs for a variety of popular programming languages and JavaScript frameworks. These SDKs are maintained by ImageKit and are designed to offer stable and feature-rich integration points. The table below lists the officially supported SDKs, their typical package names, installation commands, and their general maturity status within the ImageKit ecosystem.
| Language / Framework | Package Name | Installation Command (Example) | Maturity |
|---|---|---|---|
| JavaScript (Browser) | imagekit-javascript |
npm install imagekit-javascript |
Stable |
| React | imagekit-react |
npm install imagekit-react |
Stable |
| Vue.js | imagekit-vue |
npm install imagekit-vue |
Stable |
| Angular | imagekit-angular |
npm install imagekit-angular |
Stable |
| Next.js | imagekit-next |
npm install imagekit-next |
Stable |
| Gatsby | gatsby-imagekit |
npm install gatsby-imagekit |
Stable |
| PHP | imagekit/imagekit-php |
composer require imagekit/imagekit-php |
Stable |
| Python | imagekit |
pip install imagekit |
Stable |
| Node.js | imagekit |
npm install imagekit |
Stable |
| Java | imagekit-java (Maven/Gradle) |
Add dependency to pom.xml or build.gradle |
Stable |
| Ruby | imagekit |
Add to Gemfile: gem 'imagekit' |
Stable |
| Go | go-imagekit |
go get github.com/ImageKit/go-imagekit |
Stable |
| Dart (Flutter) | imagekit_flutter |
Add to pubspec.yaml: imagekit_flutter: ^latest_version |
Stable |
| Laravel | imagekit-laravel (PHP) |
composer require imagekit/imagekit-laravel |
Stable |
Each SDK is designed to align with the idiomatic practices of its respective language or framework, offering a native development experience. For instance, the React SDK provides components that integrate directly into React applications, while the PHP SDK offers classes for server-side operations. Developers are encouraged to consult the specific ImageKit quickstart guides for detailed usage instructions for each SDK.
Installation
The installation process for ImageKit SDKs typically follows the standard package management practices for each programming ecosystem. Below are general steps and examples for common languages. Specific version numbers should always be checked against the ImageKit SDK references for the latest recommendations.
JavaScript / Node.js / Frontend Frameworks (npm/yarn)
For JavaScript-based projects, including Node.js backends and frontend frameworks like React, Vue.js, Angular, Next.js, and Gatsby, installation is managed via npm or yarn.
# Using npm
npm install imagekit-javascript
npm install imagekit-react # For React projects
# Using yarn
yarn add imagekit-javascript
yarn add imagekit-vue # For Vue.js projects
PHP (Composer)
PHP projects utilize Composer for dependency management.
composer require imagekit/imagekit-php
composer require imagekit/imagekit-laravel # For Laravel projects
Python (pip)
Python developers use pip to install the ImageKit library.
pip install imagekit
Java (Maven/Gradle)
Java projects typically manage dependencies using Maven or Gradle. Developers need to add the ImageKit SDK to their project's pom.xml (Maven) or build.gradle (Gradle) file.
<!-- Maven pom.xml example -->
<dependency>
<groupId>io.imagekit</groupId>
<artifactId>imagekit-java</artifactId>
<version>[LATEST_VERSION]</version>
</dependency>
// Gradle build.gradle example
implementation 'io.imagekit:imagekit-java:[LATEST_VERSION]'
Ruby (Bundler/Gem)
Ruby projects use Bundler by adding the gem to their Gemfile and then running bundle install, or directly installing with gem install.
# In Gemfile
gem 'imagekit'
# Then run
bundle install
# Or direct install
gem install imagekit
Go
Go modules are used for installing the Go SDK.
go get github.com/ImageKit/go-imagekit
Dart (Flutter)
Flutter projects add the dependency to their pubspec.yaml file.
# In pubspec.yaml
dependencies:
flutter:
sdk: flutter
imagekit_flutter: ^latest_version
After adding the dependency, run flutter pub get to fetch the package.
Quickstart example
This quickstart example demonstrates how to use the ImageKit JavaScript SDK to generate an optimized image URL. The core functionality involves initializing the ImageKit instance with authentication parameters and then using its methods to construct image URLs with specified transformations. For a deeper understanding of image optimization principles, the Google Developers image optimization guide provides valuable context.
// 1. Install the SDK: npm install imagekit-javascript
// 2. Import ImageKit
import ImageKit from "imagekit-javascript";
// 3. Initialize ImageKit with your credentials
const ik = new ImageKit({
publicKey: "your_public_key",
urlEndpoint: "https://ik.imagekit.io/your_imagekit_id/",
authenticationEndpoint: "http://localhost:3000/auth"
});
// 4. Generate an optimized image URL
const imageUrl = ik.url({
path: "/default-image.jpg", // Path to the image in your ImageKit media library
urlEndpoint: "https://ik.imagekit.io/your_imagekit_id/", // Optional, if different from initialization
transformation: [{
width: "400",
height: "300",
crop: "at_max",
quality: "80"
}],
// You can also add other URL parameters like query parameters here
// queryParameters: { "v": "123" }
});
console.log("Optimized Image URL:", imageUrl);
// Example of an upload URL (requires server-side authentication endpoint)
// ik.upload({
// file: myFileObject, // A File object from an input field
// fileName: "my_new_image.jpg",
// tags: ["example", "upload"],
// folder: "/uploads/",
// }).then(result => {
// console.log("Upload successful:", result);
// }).catch(error => {
// console.error("Upload failed:", error);
// });
This example demonstrates how to configure the ImageKit instance with a publicKey, urlEndpoint, and authenticationEndpoint. The url() method is then used to specify the image path and an array of transformations. The resulting imageUrl will be an optimized URL that ImageKit's CDN can serve. The authenticationEndpoint is crucial for secure operations like file uploads, as it allows your server to generate authenticated tokens without exposing private keys on the client side. For more advanced features and server-side operations, refer to the ImageKit API reference.
Community libraries
While ImageKit maintains a comprehensive suite of official SDKs, the broader developer community may also contribute libraries or integrations that extend ImageKit's functionality or provide alternative ways to interact with its services. These community-driven projects can sometimes offer specialized features, different architectural approaches, or support for niche platforms not covered by official SDKs. However, it is important to note that community libraries may not always receive the same level of ongoing support, updates, or security audits as official offerings. Developers choosing community libraries should review their documentation, community activity, and maintenance status.
As of the current date, ImageKit primarily emphasizes its official SDKs, which cover a wide array of popular languages and frameworks. Any significant community-contributed libraries would typically be referenced within the official ImageKit documentation if they gain substantial adoption and meet certain quality standards. For the most up-to-date information on any officially recognized community contributions, developers should consult the official ImageKit SDK and API documentation.