Skip to content

ImageKit

Website: imagekit.io

ImageKit is a cloud-based image optimization and CDN service used for all file uploads (photos, documents, videos) in Sutomo.

Overview

All uploaded files pass through ImageKit for:

  • CDN delivery — fast global distribution
  • Automatic optimization — WebP conversion, compression, resizing
  • URL-based transformations — resize/crop on the fly via URL parameters
  • Private file support — signed URLs for sensitive documents

Integration

Flow

  1. User uploads a file → Asset model saves with uploadedFile property
  2. AssetObserver triggers → calls ImageKitService
  3. Service prepares (compress, resize, convert to WebP) then uploads to ImageKit
  4. ImageKit returns a CDN URL → stored in assets.path
  5. All subsequent access uses the CDN URL

Environment Variables

env
IMAGEKIT_PUBLIC_KEY=your_public_key
IMAGEKIT_PRIVATE_KEY=your_private_key
IMAGEKIT_URL_ENDPOINT=https://ik.imagekit.io/your_account

Development Credentials

Shared ImageKit account for local development (owned by the team). Use these in your local .env so everyone works against the same dev CDN.

VariableValue
IMAGEKIT_PUBLIC_KEYpublic_JbmUC2vzh0wfdHxU5SgujPPIke0=
IMAGEKIT_PRIVATE_KEYprivate_bJCqmAqNI5iGaRtDFODSfTZXCIc=
IMAGEKIT_URL_ENDPOINThttps://ik.imagekit.io/o2epoyqvj/

Sign in at imagekit.io with:

  • Email: dev@icanntechindo.com
  • Password: Dev_test@2026

⚠️ These are development credentials only — never use them in production. Production keys live in the deployment environment, not in .env.


URL Transformations

ImageKit supports on-the-fly transformations via URL parameters:

php
// Original: https://ik.imagekit.io/sutomo/schools/photos/student_abc.jpg

// Resize to 200x200
// https://ik.imagekit.io/sutomo/schools/photos/student_abc.jpg?tr=w-200,h-200

// Crop to square
// https://ik.imagekit.io/sutomo/schools/photos/student_abc.jpg?tr=w-200,h-200,cm-pad_resize

// WebP format
// https://ik.imagekit.io/sutomo/schools/photos/student_abc.jpg?tr=f-webp

Key Files

FilePurpose
app/Services/Asset/ImageKitService.phpUpload orchestration — prepare, upload, option resolution
app/Services/Asset/CompressService.phpIterative image compression
app/Services/Asset/ResizeService.phpImage resizing/scaling
app/Services/Asset/ConversionService.phpWebP conversion
app/Observers/Platform/AssetObserver.phpAuto-trigger upload on Asset save
.envIMAGEKIT_* credentials