Supported Versions: PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8
Get Mime-Type for image-type returned by getimagesize, exif_read_data, exif_thumbnail, exif_imagetype
<?php image_type_to_mime_type(int $image_type): string
<?php {
ob_start();
imagejpeg($this->image->getCore(), null, $this->quality);
$this->image->mime = image_type_to_mime_type(IMAGETYPE_JPEG);
$buffer = ob_get_contents();
ob_end_clean();
<?php imagealphablending($resource, false);
imagesavealpha($resource, true);
imagepng($resource, null, -1);
$this->image->mime = image_type_to_mime_type(IMAGETYPE_PNG);
$buffer = ob_get_contents();
ob_end_clean();
<?php {
ob_start();
imagegif($this->image->getCore());
$this->image->mime = image_type_to_mime_type(IMAGETYPE_GIF);
$buffer = ob_get_contents();
ob_end_clean();
<?php imagealphablending($this->image->getCore(), true);
imagesavealpha($this->image->getCore(), true);
imagewebp($this->image->getCore(), null, $this->quality);
$this->image->mime = defined('IMAGETYPE_WEBP') ? image_type_to_mime_type(IMAGETYPE_WEBP) : 'image/webp';
$buffer = ob_get_contents();
ob_end_clean();
<?php ob_start();
imagebmp($this->image->getCore());
$this->image->mime = defined('IMAGETYPE_BMP') ? image_type_to_mime_type(IMAGETYPE_BMP) : 'image/bmp';
$buffer = ob_get_contents();
ob_end_clean();
<?php $imagick->setCompression($compression);
$imagick->setImageCompression($compression);
$this->image->mime = image_type_to_mime_type(IMAGETYPE_PNG);
return $imagick->getImagesBlob();
}
<?php $imagick->setCompression($compression);
$imagick->setImageCompression($compression);
$this->image->mime = image_type_to_mime_type(IMAGETYPE_GIF);
return $imagick->getImagesBlob();
}
<?php $imagick->setCompressionQuality($this->quality);
$imagick->setImageCompressionQuality($this->quality);
$this->image->mime = image_type_to_mime_type(IMAGETYPE_TIFF_II);
return $imagick->getImagesBlob();
}
<?php $imagick->setCompression($compression);
$imagick->setImageCompression($compression);
$this->image->mime = image_type_to_mime_type(IMAGETYPE_BMP);
return $imagick->getImagesBlob();
}
<?php $imagick->setCompression($compression);
$imagick->setImageCompression($compression);
$this->image->mime = image_type_to_mime_type(IMAGETYPE_ICO);
return $imagick->getImagesBlob();
}
<?php $imagick->setCompression($compression);
$imagick->setImageCompression($compression);
$this->image->mime = image_type_to_mime_type(IMAGETYPE_PSD);
return $imagick->getImagesBlob();
}