webCOMAND

ImageData::get_mime()

Get the MIME-type based on the image format.

Prototype

string get_mime()

Return

The image MIME-type based on the image format.  Common MIME types include:

  • image/png
  • image/jpeg
  • image/gif

Example

// load a PNG image from the web
$url = 'https://www.webcomand.com/docs/img/note.png';
$image = get_file_contents($url);
$image = new \io_comand_image\models\ImageData($image);

// get the PNG MIME type
$before = $image->get_mime();

// change the image format to JPEG
$image->set_format('JPEG');

// get the JPEG MIME type
$after = $image->get_mime();

// display the MIME type from before and after conversion
echo("Converted image from $before to $after.\n");