Image Resizer

asciito

AuthorasciitoPlugin TypeCommunity PluginPriceFreeVersionv0.1.0LicenseMIT
NativePHP^3.2PHP^8.2iOSanyAndroidany

NativePHP Mobile plugin that downscales images using native APIs — ImageIO on iOS and BitmapFactory on Android.

Install

composer require coyotito/image-resizer

Register the plugin it the NativeServiceProvider:

public function plugins(): array
{
    return [
        \Coyotito\ImageResizer\ImageResizerServiceProvider::class,
    ];
}

Usage

use Coyotito\ImageResizer\Facades\ImageResizer;

$ok = ImageResizer::resize(
    sourcePath: '/abs/path/to/source.jpg',
    targetPath: '/abs/path/to/target.jpg',
    maxSide: 1024,   // longest side cap; preserves aspect ratio, no upscale
    quality: 80,     // JPEG quality, 0-100
);

Returns true on success, false otherwise. Target is always written as JPEG. EXIF orientation is respected on both platforms.

Platform notes

Feature iOS Android
Decoder CGImageSource (ImageIO) BitmapFactory with inSampleSize
EXIF orientation Auto via thumbnail transform Explicit via ExifInterface
Output format JPEG JPEG
Memory efficiency Thumbnail API streams from disk inSampleSize downsamples on read