Me again if the jpegs have an EXIF file you can get the data from it in php.
Here’s a test script that I did:
<?php
$file_name = 'assets/large/img-photos-1554676248.jpg';
//$file_name = 'assets/large/img-photos-1554676248.jpg';
$exif_data = exif_read_data($file_name);
echo "<pre>" . print_r($exif_data, 1) . "</pre>";
if ($exif_data['Model']) {
$photos[] = [
'FileName' => $exif_data['FileName'],
'Model' => "Sony " . $exif_data['Model'],
'ExposureTime' => $exif_data['ExposureTime'] . "s",
'Aperture' => "f/" . intval($exif_data['FNumber']),
'ISO' => $exif_data['ISOSpeedRatings'],
'FocalLength' => $exif_data['FocalLengthIn35mmFilm'] . "mm",
];
}
echo "<pre>" . print_r($photos, 1) . "</pre?";
Here’s a process file of my website, this is where I upload my images:
<?php
require_once '../private/initialize.php';
use Library\ProcessImage\ProcessImage as Process;
use Library\Resize\Resize;
use Library\Journal\Journal;
use Library\CMS\CMS;
use Library\Users\Users;
use Library\Read\Read;
$result = false;
$fetchUsername = new Users;
//echo $_SESSION['username'] . "<br>";
$username = $fetchUsername->username();
$journal = new Journal();
/*
* If user is updating blog or home page.
*/
$update = filter_input(INPUT_POST, 'action', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
if (isset($update) && $update === 'update') {
$data['id'] = filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT);
$data['author'] = $username;
$data['page_name'] = filter_input(INPUT_POST, 'page_name', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$data['heading'] = filter_input(INPUT_POST, 'heading', FILTER_DEFAULT);
$data['content'] = filter_input(INPUT_POST, 'content', FILTER_DEFAULT);
$data['rating'] = filter_input(INPUT_POST, 'rating', FILTER_SANITIZE_NUMBER_INT);
$data['category'] = filter_input(INPUT_POST, 'category', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$result = $journal->update($data);
if ($result) {
header("Location: " . $result);
exit();
}
}
$upload = filter_input(INPUT_POST, 'action', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$data['user_id'] = filter_input(INPUT_POST, 'user_id', FILTER_SANITIZE_NUMBER_INT);
$data['author'] = $username;
$data['page_name'] = filter_input(INPUT_POST, 'page_name', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$data['heading'] = filter_input(INPUT_POST, 'heading', FILTER_DEFAULT);
$data['content'] = filter_input(INPUT_POST, 'content', FILTER_DEFAULT);
$data['rating'] = filter_input(INPUT_POST, 'rating', FILTER_SANITIZE_NUMBER_INT);
$data['category'] = filter_input(INPUT_POST, 'category', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
//echo "<pre>" . print_r($data, 1). "</pre>";
if ($_FILES['file']['error'] !== 4) {
$file = $_FILES['file']; // Assign image data to $file array:
$thumbImage = $_FILES['file'];
$imgObject = new Process($file, 'photos-');
$check['image_status'] = $imgObject->processImage();
$check['file_type'] = $imgObject->checkFileType();
$check['file_ext'] = $imgObject->checkFileExt();
$exif_data = exif_read_data($imgObject->saveIMG());
if ($exif_data['Model']) {
$data['Model'] = "Sony " . $exif_data['Model'];
$data['ExposureTime'] = $exif_data['ExposureTime'] . "s";
$data['Aperture'] = $exif_data['COMPUTED']['ApertureFNumber'];
$data['ISO'] = "ISO " . $exif_data['ISOSpeedRatings'];
$data['FocalLength'] = $exif_data['FocalLengthIn35mmFilm'] . "mm";
}
//echo "<pre>" . print_r($data, 1) . "</pre?";
//echo "<pre>" . print_r($check, 1) . "</pre>\n";
if (in_array(TRUE, $check)) {
$errMsg = "There's something wrong with the image file!<b>";
} else {
$data['image_path'] = $imgObject->saveIMG();
// *** 1) Create a new instance of class Resize:
$resizePic = new Resize($data['image_path']);
// *** 2) Resize image (options: exact, portrait, landscape, auto, crop)
$resizePic->resizeImage(2048, 1365, 'exact');
// *** 3) Save image to directory:
$resizePic->saveImage($data['image_path'], 100);
}
$thumbObject = new Process($thumbImage, 'photos-', false);
$check['image_status'] = $thumbObject->processImage();
$check['file_type'] = $thumbObject->checkFileType();
$check['file_ext'] = $thumbObject->checkFileExt();
//echo "<pre>" . print_r($check, 1) . "</pre>\n";
if (in_array(TRUE, $check)) {
$errMsg = "There's something wrong with the image file!<b>";
} else {
$data['thumb_path'] = $thumbObject->saveIMG();
copy($data['image_path'], $data['thumb_path']);
// *** 1) Create a new instance of class Resize:
$resizePic = new Resize($data['thumb_path']);
// *** 2) Resize image (options: exact, portrait, landscape, auto, crop)
$resizePic->resizeImage(600, 400, 'exact');
// *** 3) Save image to directory:
$resizePic->saveImage($data['thumb_path'], 100);
/*
* Save all the data from the form to the database table: cms
*/
$result = $journal->create($data);
if ($result) {
header("Location: " . $result);
exit();
}
}
}