Meta Information
Read Meta Data from Images
2.9M Downloads / Month
Open Source MIT License
2.9M Downloads / Month
Open Source MIT License
public Image::width(): integer
Reading the width in pixels from an image instance.
use Intervention\Image\ImageManager;
use Intervention\Image\Drivers\Imagick\Driver;
// create new manager instance with desired driver
$manager = new ImageManager(new Driver());
// reading an image
$image = $manager->read('images/example.png');
// reading the image width
$width = $image->width();
public Image::height(): integer
Reading the pixel height from an image instance.
use Intervention\Image\ImageManager;
use Intervention\Image\Drivers\Gd\Driver;
// create new manager instance with desired driver
$manager = new ImageManager(new Driver());
// reading an image
$image = $manager->read('images/example.png');
// reading the image height
$height = $image->height();
public Image::size(): SizeInterface
Reading the image size from an instance.
use Intervention\Image\ImageManager;
use Intervention\Image\Drivers\Imagick\Driver;
// create new manager instance with desired driver
$manager = new ImageManager(Driver::class);
// reading an image
$image = $manager->read('images/example.png');
// read image size
$size = $image->size();
// read aspect ratio
$ratio = $size->aspectRatio();
// determine image format
$is_portrait = $size->isPortrait(); // true
$is_landscape = $size->isLandscape(); // false
// read width from size
$width = $size()->width();
public Image::resolution(): ResolutionInterface
Reads out the image resolution of the current instance in DPI.
use Intervention\Image\ImageManager;
use Intervention\Image\Drivers\Gd\Driver;
// create new manager instance with desired driver
$manager = new ImageManager(Driver::class);
// reading an image
$image = $manager->read('images/example.png');
// read image resolution object
$resolution = $image->resolution();
// convert resolution to dpcm
$resolution = $resolution->perCm();
// read resolution for each axis
$x = $resolution->x();
$y = $resolution->y();
public Image::setResolution(float $x, float $y): ImageInterface
Set the image resolution in DPI for each axis. Please note that the resolution is encoded only for image formats that support this feature.
Name | Type | Description |
---|---|---|
x | float | Resolution on the x-axis |
y | float | Resolution on the y-axis |
use Intervention\Image\ImageManager;
use Intervention\Image\Drivers\Gd\Driver;
// create new manager instance with desired driver
$manager = new ImageManager(new Driver());
// read an image
$image = $manager->read('images/example.jpg');
// set image resolution to 300 DPI
$image->setResolution(300, 300);
Currently Intervention Image is only able to read Exif information. The possibility to write Exif data blocks is not implemented.
public Image::exif(?string $query = null): mixed
This function reads Exif information from the current image instance. You have
the option to pass a parameter to read a specific block of information from the
Exif data directly. If no parameter is passed, all data will be returned. If
the specified block is not found, null
is returned as result.
To use this function, the PHP Exif extension must be installed.
Name | Type | Description |
---|---|---|
query | string or null | Optionally query exif information block directly |
use Intervention\Image\ImageManager;
use Intervention\Image\Drivers\Imagick\Driver;
// create new manager instance with desired driver
$manager = new ImageManager(new Driver());
// reading an image
$image = $manager->read('images/example.jpg');
// read the specific exif data
$camera = $image->exif('IFD0.Model');
// read all exif information
$all = $image->exif();
// the exif data block can be queried as well
$camera = $all->get('IFD0.Model');
Edit