Finding out what file type something is in php
You can use php build in function: https://secure.php.net/manual/de/function.mime-content-type.php
<?php
echo mime_content_type('php.gif') . "\n";
echo mime_content_type('test.php');
?>
Will output:
image/gif
text/plain
Condition Example I: JPG Images only
if (\mime_content_type('image.jpg' /* full path to image */) === "image/jpg") {
// do something
}
Condition Example II: Any type of images
if (\strpos(\mime_content_type('image.jpg' /* full path to image */), 'image/') !== false) {
// do something
}
How to get the image type in php
use getimagesize() or exif_imagetype()
// integer - for example: IMAGETYPE_GIF, IMAGETYPE_JPEG etc.
$type = exif_imagetype($_FILES['image']['tmp_name']);
and
$info = getimagesize($_FILES['image']['tmp_name']);
$mime = $info['mime']; // mime-type as string for ex. "image/jpeg" etc.
$width = $info[0]; // width as integer for ex. 512
$height = $info[1]; // height as integer for ex. 384
$type = $info[2]; // same as exif_imagetype
Mind that exif_imagetype
is much faster than getimagesize
. Check documentation for more info.
How can find image type without extension in php?
You can use getimagesize to get the mime type, and switch on the type to create generate extension.
In code this could look like something like this:
$image_info = getImageSize($path);
switch ($image_info['mime']) {
case 'image/gif':
$extension = '.gif';
break;
case 'image/jpeg':
$extension = '.jpg';
break;
case 'image/png':
$extension = '.png';
break;
default:
// handle errors
break;
}
Auto Detect Image for 360 nature in PHP
According to Facebook 360 Group:
There isn't yet a standard for tagging a photo as containing 360 content.
It suggest that you look for the EXIF tag
Projection Type : equirectangular
You can also look for
Use Panorama Viewer : True
Those two tags are present on photos taken with my LG 360.
Related Topics
Angularjs Upload Multiple Files with Formdata API
PHP Include Error Not Findind the Path
JSON_Encode Function: Special Characters
Mechanisms for Tracking Db Schema Changes
Magento - Retrieve Products with a Specific Attribute Value
Combinations, Dispositions and Permutations in PHP
How to Access an Object Attribute That Starts with a Number
Send Cookie with File_Get_Contents
How to Make Number_Format() Not to Round Numbers Up
Doctrine Query Language Get Max/Latest Row Per Group
Executing MySQLi_Query Inside a Function
How to Get Rid of MySQL Error 'Prepared Statement Needs to Be Re-Prepared'
Least Memory Intensive Way to Read a File in PHP
How to Send Email from Localhost Wamp Server to Send Email Gmail Hotmail or So Forth