What is the Image Manipulation library in CodeIgniter 4?
Answer
CI4 provides an Image class for common image manipulation tasks. Load an image: $image = Services::image()->withFile("/path/to/image.jpg"). Resize: $image->resize(200, 200, true)->save("/path/to/thumb.jpg") (third parameter: maintain aspect ratio). Crop: $image->crop(100, 100, 10, 10) (width, height, x, y). Rotate: $image->rotate(90). Flip: $image->flip("horizontal"). Convert: $image->convert(IMAGETYPE_WEBP). Watermark text: $image->text("© My App", ["color" => "#fff", "opacity" => 50, "withShadow" => true]). Fit (crop to fit): $image->fit(200, 200, "center"). CI4 supports GD2, ImageMagick, and Netpbm drivers — configure in app/Config/Images.php. Chain operations: $image->resize(800, 600, true)->watermarkText("©")->save().
Previous
What is CodeIgniter 4's Language/Localization system?
Next
What is route caching and performance in CodeIgniter 4?