PHP exif_read_data():无法打开文件查询

I'm trying to sort an array of image files by EXIF DateTime Original replacing the the original code used to sort the images by mtime using stat().

The original code used to sort the image files by mtime is as follows:

// display photos in album
$src_folder = $mainFolder.'/'.$_REQUEST['album']; 
$src_files = array_diff(scandir($src_folder ), array('..', '.'));
$files = array();

/*** sort by most recent uploaded file ***/
foreach ($src_files as $key=>$img) {
    $stat_folders = stat($src_folder .'/'. $img);
    $file_time[$key] = $stat_folders['ctime'];
}
array_multisort($file_time, SORT_DESC, $src_files);
/*** end sort ***/

I've tested the following code that achieves the sorting of the array as required:

function getExifDate($filename)
{
    $exif_odate = exif_read_data($filename, 0, true);
    if($exif_odate === false){
        return filemtime($filename);
    }
    if(isset($exif_odate['EXIF']['DateTimeOriginal'])){
        return strtotime($exif_odate['EXIF']['DateTimeOriginal']);
    } else {
        return filemtime($filename);
    }
}
$src_folder = 'folder/'; 
$src_files = glob($src_folder . '*.jpg'); 
array_multisort(array_map('getExifDate', $src_files), SORT_NUMERIC, SORT_DESC, $src_files);

However, when I try to integrate the new sort method using the following code:

// display photos in album
$src_folder = $mainFolder.'/'.$_REQUEST['album']; 
$src_files = array_diff(scandir($src_folder ), array('..', '.'));
$files = array();

/*** sort files by date photo taken ***/
function getExifDate(){
    global $src_folder, $src_files;

    $src_images = array();
    foreach ($src_files as $img){       
        $exif_odate = exif_read_data($img, 0, true);
        //      $exif_odate = exif_read_data($src_folder . $img, "FILE,COMPUTED,ANY_TAG,IFD0,THUMBNAIL,COMMENT,EXIF", true);   <-- doesn't work either!
        $src_date = strtotime($exif_odate['EXIF']['DateTimeOriginal']);
        $src_images[$img] = $src_date;
    }
}
array_multisort(array_map('getExifDate', $src_files), SORT_NUMERIC, SORT_DESC, $src_files);
/*** end sort ***/

When the page is loaded the following error message is generated for each of the image files attempted to be read:

Warning: exif_read_data(): Unable to open file in ...

referring to the following line of code:

$exif_odate = exif_read_data($img, 0, true);

Changing that line of code to the following makes no difference:

$exif_odate = exif_read_data($src_folder . $img, "FILE,COMPUTED,ANY_TAG,IFD0,THUMBNAIL,COMMENT,EXIF", true);

... and the image thumbnails are displayed unsorted ... inevitably.

Any guidance as to how to resolve this issue would be appreciated.

donglianjiang9321
donglianjiang9321 感谢您的指导,04FS。非常感谢。
大约一年之前 回复
du59131
du59131 $src_folder实际上有一个尾部斜杠吗?否则,您当然需要在文件夹名称和文件名之间插入它。
大约一年之前 回复

1个回答

Thanks to 04FS for helping me to resolve the issue:

Simply replacing the following original code:

/*** sort by most recent uploaded file ***/
foreach ($src_files as $key=>$img) {
    $stat_folders = stat($src_folder .'/'. $img);
    $file_time[$key] = $stat_folders['ctime'];
}
array_multisort($file_time, SORT_DESC, $src_files);
/*** end sort ***/

with:

/*** sort files by date photo taken ***/
foreach ($src_files as $key=>$img){       
    $exif_odate = exif_read_data($src_folder . '/' . $img, 0, true);
    $file_time[$key] = strtotime($exif_odate['EXIF']['DateTimeOriginal']);
}
array_multisort($file_time, SORT_NUMERIC, SORT_DESC, $src_files);
/*** end sort ***/

resolved the sorting issue. :)

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
将文件移动到其他服务器后,为什么exif_read_data()无法正常工作?

<div class="post-text" itemprop="text"> <p>I am attempting to move a program from one server to another and the same script will not work and I can't figure out why...The below is a scaled down version of my script that fails:</p> <pre><code>&lt;?php error_reporting(E_ALL); ini_set('display_errors', 1); $string=file_get_contents("../photos/report14/concreteCurb/baseCompaction1.jpeg"); $exif = exif_read_data("data:image/jpeg;base64," . base64_encode($string)); print_r($exif); ?&gt; </code></pre> <p>The server that works spits out a simple</p> <pre><code>Array ( [FileName] =&gt; Z [FileDateTime] =&gt; 0 [FileSize] =&gt; 137976 [FileType] =&gt; 2 [MimeType] =&gt; image/jpeg [SectionsFound] =&gt; COMMENT [COMPUTED] =&gt; Array ( [html] =&gt; width="773" height="1000" [Height] =&gt; 1000 [Width] =&gt; 773 [IsColor] =&gt; 1 ) [COMMENT] =&gt; Array ( [0] =&gt; CREATOR: gd-jpeg v1.0 (using IJG JPEG v90), quality = 90 ) ) </code></pre> <p>...but the one that doesn't throws...</p> <pre><code>Warning: exif_read_data(): Unable to open file in /nfs/c11/h01/mnt/208416/domains/s208416.gridserver.com/html/advantage/scripts/test.php on line 5 </code></pre> <p>Both have EXIF Support enabled (both version 1.4). PHP version on the old server is 5.3.5 whereas the new has 5.5.21, but I also tried it reverted back to 5.3.29 to no avail.</p> </div>

PHP:exif_read_data()未定义

<div class="post-text" itemprop="text"> <p>I'm now learning how to extract exif from images.I wrote the simple code like this:</p> <pre><code>&lt;?php //Get the exif data $exif_data = exif_read_data('sample.jpg'); print_r($exif_data); ?&gt; </code></pre> <p>But, there is a fatal error about undefined exif_read_data() when running the code. I'm a windows user, and I have modified the php.ini like this :</p> <pre><code>extension=php_mbstring.dll extension=php_exif.dll </code></pre> <p>Thanks for your help.</p> </div>

PHP exif_read_data不返回方向

<div class="post-text" itemprop="text"> <p>I am using <code>exif_read_data</code>, but it is not returning images orientation. Below is my code:</p> <pre><code>$path = base_url()."assets/procedure_logo/".$procedure_logo; print_r($path); $exif = exif_read_data($path,"FILE,COMPUTED,ANY_TAG,IFD0,THUMBNAIL,COMMENT,EXIF", true); print_r($exif); die(); </code></pre> <p>Print path in I get fullpath like </p> <p><a href="http://www.ilockitout.net/assets/procedure_logo/12848C457-0482-495A-8756-038C9B7980501344008487.JPG" rel="nofollow noreferrer">http://www.ilockitout.net/assets/procedure_logo/12848C457-0482-495A-8756-038C9B7980501344008487.JPG</a></p> <p>When I print <code>$exif</code> I got array like this:</p> <pre><code>Array ( [FILE] =&gt; Array ( [FileName] =&gt; 12848C457-0482-495A-8756-038C9B7980501344008487.JPG [FileDateTime] =&gt; 0 [FileSize] =&gt; 25770 [FileType] =&gt; 2 [MimeType] =&gt; image/jpeg [SectionsFound] =&gt; COMMENT ) [COMPUTED] =&gt; Array ( [html] =&gt; width="640" height="480" [Height] =&gt; 480 [Width] =&gt; 640 [IsColor] =&gt; 1 ) [COMMENT] =&gt; Array ( [0] =&gt; CREATOR: gd-jpeg v1.0 (using IJG JPEG v80), quality = 50 ) ) </code></pre> </div>

依赖于exif_read_data()的代码会停止生成预期的输出

<div class="post-text" itemprop="text"> <p>I have a photoblog which prints out EXIF info from my images (<a href="http://php.net/manual/en/function.exif-read-data.php" rel="nofollow">http://php.net/manual/en/function.exif-read-data.php</a>).</p> <p>Worked great, until today. It just stopped printing out the data. I have not made any changes to the files.</p> <p>The images are located in wordpress upload folder. If i try with an image+exif php file in public_html, i get the data as usual. What could have caused this? Thanks!</p> </div>

php exif_read_data()不在utf-8中

<div class="post-text" itemprop="text"> <p>So I'm using <code>glob()</code> function in <code>foreach</code> to render images from folder on my site and I want to have titles in there, so I put title in meta data of that image, but when I execute those meta data via exif_read_data() it will execute not in utf-8, it shows POL`T?XE this instead of this POLŠTÁŘE. This is my code with some tries of solving this problem</p> <pre><code>header("Content-Type: text/html; charset=utf-8"); ini_set('exif.encode_unicode', 'UTF-8'); iconv_set_encoding('input_encoding', 'UTF-8'); iconv_set_encoding('output_encoding', 'UTF-8'); iconv_set_encoding('internal_encoding', 'UTF-8'); $dirs = array_filter(glob('img/*'), 'is_dir'); foreach ($dirs as $dir) { $files = glob($dir.'/*.{jpg,png,JPG,PNG,jpeg,JPEG}', GLOB_BRACE); foreach($files as $file) { $meta_data = exif_read_data($file, 0, true); echo ' &lt;img src="'.$file.'" title="'.$meta_data['IFD0']['Title'].'" /&gt; '; } } </code></pre> <p>Nothing of it worked, even when I used exiftools. Not even with <code>utf8_encode()</code> and not even <code>mb_convert_encoding($meta_data['IFD0']['Title'], 'UTF-8')</code>. When I used this <code>mb_detect_encoding()</code> function it executed UTF-8.</p> <p>And I tried to set encoding to utf-8 with exiftool and it didn't work either. Can you help me?</p> </div>

使用PHP exif_read_data获取照片的“拍摄日期”而不是“修改日期”

<div class="post-text" itemprop="text"> <p>I'm retrieving the creation date from a photo with exif_read_data PHP function (see the code below.) The dates retrieved from photos that haven't been modified return "Date Taken". Those that have been modified - "Date Modified". Is there a way to get the date a photo was taken, ignoring the "Date Modified" field?</p> <pre><code>$exif_data = exif_read_data ($filename); if (!empty($exif_data['DateTime'])) { $exif_date = $exif_data['DateTime']; } </code></pre> <p>Thank you.</p> <p>Edit: I think $exif_data['DateTime'] uses the first available date field. Since unmodified images had the same value for "Date Modified" and "Date Taken" it was always retrieving "Date Modified" in my case.</p> </div>

exif_read_data vs exec(exiftool ...)

<div class="post-text" itemprop="text"> <p>i have the following problem:</p> <p>I work in maintenance in a new inherited project. In this project the developers work on metadata of image and video in this way:</p> <pre><code>function getRotationFromFile($realPath) { $retVal = Array(); $cmd = variable_get("exiftool",null) . "\"$realPath\"" . " | grep -E 'Rotation|Camera Identifier'"; exec($cmd, $output); foreach ($output as $row){ $key = trim(strstr($row, ':', true)); $value = trim(str_replace(": ", "", strstr($row, ': '))); $retVal[$key] = $value; } return $retVal; } </code></pre> <p>As you can read, this function, call the <em>exec(exiftool..)</em> and retrieve some metadata. I know that in php exists <a href="http://www.php.net/manual/en/function.exif-read-data.php" rel="nofollow">exif_read_data</a>, that done the same.</p> <p>My questions are:</p> <ol> <li>What is the best solution?</li> <li>Who is the faster one?</li> <li>Who is the more "correct" one?</li> <li>Finally, i try to search but i don't find if <strong>exif_read_data</strong> use <em>exiftool</em> in source</li> </ol> <p>Thank you in advance!</p> </div>

如何在linux系统中的php上安装exif扩展

<div class="post-text" itemprop="text"> <p>I want to upload images.but program have a fatal error:undefined function exif_read_data(),I don't know how to install exif extension in php on linux system.Hope the junior help me.Thank you very much.</p> </div>

PHP read_exif_data和调整方向

<div class="post-text" itemprop="text"> <p>I am using the following code to rotate an uploaded jpeg image if the orientation is off. I am only having problems with images uploaded from iPhones and Android.</p> <pre><code>if(move_uploaded_file($_FILES['photo']['tmp_name'], $upload_path . $newfilename)){ chmod($upload_path . $newfilename, 0755); $exif = exif_read_data($upload_path . $newfilename); $ort = $exif['IFD0']['Orientation']; switch($ort) { case 3: // 180 rotate left $image-&gt;imagerotate($upload_path . $newfilename, 180, -1); break; case 6: // 90 rotate right $image-&gt;imagerotate($upload_path . $newfilename, -90, -1); break; case 8: // 90 rotate left $image-&gt;imagerotate($upload_path . $newfilename, 90, -1); break; } imagejpeg($image, $upload_path . $newfilename, 100); $success_message = 'Photo Successfully Uploaded'; }else{ $error_count++; $error_message = 'Error: Upload Unsuccessful&lt;br /&gt;Please Try Again'; } </code></pre> <p>Am I doing something wrong with the way I am reading the EXIF data from the jpeg? It is not rotating the images as it is supposed to.</p> <p>This is what happens when I run a var_dump($exif);</p> <pre><code>array(41) { ["FileName"]=&gt; string(36) "126e7c0efcac2b76b3320e6187d03cfd.JPG" ["FileDateTime"]=&gt; int(1316545667) ["FileSize"]=&gt; int(1312472) ["FileType"]=&gt; int(2) ["MimeType"]=&gt; string(10) "image/jpeg" ["SectionsFound"]=&gt; string(30) "ANY_TAG, IFD0, THUMBNAIL, EXIF" ["COMPUTED"]=&gt; array(8) { ["html"]=&gt; string(26) "width="2048" height="1536"" ["Height"]=&gt; int(1536) ["Width"]=&gt; int(2048) ["IsColor"]=&gt; int(1) ["ByteOrderMotorola"]=&gt; int(1) ["ApertureFNumber"]=&gt; string(5) "f/2.8" ["Thumbnail.FileType"]=&gt; int(2) ["Thumbnail.MimeType"]=&gt; string(10) "image/jpeg" } ["Make"]=&gt; string(5) "Apple" ["Model"]=&gt; string(10) "iPhone 3GS" ["Orientation"]=&gt; int(6) ["XResolution"]=&gt; string(4) "72/1" ["YResolution"]=&gt; string(4) "72/1" ["ResolutionUnit"]=&gt; int(2) ["Software"]=&gt; string(5) "4.3.5" ["DateTime"]=&gt; string(19) "2011:09:16 21:18:46" ["YCbCrPositioning"]=&gt; int(1) ["Exif_IFD_Pointer"]=&gt; int(194) ["THUMBNAIL"]=&gt; array(6) { ["Compression"]=&gt; int(6) ["XResolution"]=&gt; string(4) "72/1" ["YResolution"]=&gt; string(4) "72/1" ["ResolutionUnit"]=&gt; int(2) ["JPEGInterchangeFormat"]=&gt; int(658) ["JPEGInterchangeFormatLength"]=&gt; int(8231) } ["ExposureTime"]=&gt; string(4) "1/15" ["FNumber"]=&gt; string(4) "14/5" ["ExposureProgram"]=&gt; int(2) ["ISOSpeedRatings"]=&gt; int(200) ["ExifVersion"]=&gt; string(4) "0221" ["DateTimeOriginal"]=&gt; string(19) "2011:09:16 21:18:46" ["DateTimeDigitized"]=&gt; string(19) "2011:09:16 21:18:46" ["ComponentsConfiguration"]=&gt; string(4) "" ["ShutterSpeedValue"]=&gt; string(8) "3711/949" ["ApertureValue"]=&gt; string(9) "4281/1441" ["MeteringMode"]=&gt; int(1) ["Flash"]=&gt; int(32) ["FocalLength"]=&gt; string(5) "77/20" ["SubjectLocation"]=&gt; array(4) { [0]=&gt; int(1023) [1]=&gt; int(767) [2]=&gt; int(614) [3]=&gt; int(614) } ["FlashPixVersion"]=&gt; string(4) "0100" ["ColorSpace"]=&gt; int(1) ["ExifImageWidth"]=&gt; int(2048) ["ExifImageLength"]=&gt; int(1536) ["SensingMethod"]=&gt; int(2) ["ExposureMode"]=&gt; int(0) ["WhiteBalance"]=&gt; int(0) ["SceneCaptureType"]=&gt; int(0) ["Sharpness"]=&gt; int(1) } </code></pre> </div>

使用PHP从HEIC照片中读取EXIF数据

<div class="post-text" itemprop="text"> <p>I want to read the EXIF data from a HEIC photo.</p> <p>If I run:</p> <pre><code>&lt;?php var_dump(exif_read_data("test.heic")); </code></pre> <p>I get</p> <pre><code>bool(false) </code></pre> <p>If I run the Linux tool <code>exiftool test.heic</code> - then I can see all the information that I need is there (location, camera name, etc).</p> <p>If I run <code>exif_read_data("test.jpg")</code> - then I get data. So I know the syntax I'm using is correct.</p> <p>I'm using PHP 7.1 and ImageMagick 6.9.4-10 (1684).</p> <pre><code>print_r(imagick::getVersion()); Array ( [versionNumber] =&gt; 1684 [versionString] =&gt; ImageMagick 6.9.4-10 Q16 x86_64 2017-05-23 http://www.imagemagick.org ) </code></pre> <p>Do I need newer versions? If so, which ones work with HEIC?</p> </div>

如何在laravel中使用exif()提取和传递exif数据(数组)?

<div class="post-text" itemprop="text"> <p>I am creating a photo stock system and want to extract <code>exif()</code> data of images that users add. I am not sure how to pass the array of <code>exif()</code> into database and then display that data in view. For that I have created a row as <code>string(p_exif)</code> in the migration. What am I doing wrong?</p> <p>I have tried passing data in array but it seems to not work.</p> <p>I initially ran this code to save image on my project folder:</p> <pre><code>Image::make($image)-&gt;resize(640,390)-&gt;save($location); </code></pre> <p>Later to extract exif data, I ran this code:</p> <pre><code>$data = Image::make($image)-&gt;resize(640,390)-&gt;save($location)-&gt;exif(); </code></pre> <p>But it seems I am making a mistake here that I'm not being able to figure out. I am not sure how to pass the array <code>$data</code> into the database and then to view. </p> <p>I want to store <code>exif()</code> data array in the database. The error says something about not passing arrays.</p> </div>

PHP的EXIF数据错误[重复]

<div class="post-text" itemprop="text"> <div class="question-status question-originals-of-duplicate"> <p>This question already has an answer here:</p> <ul> <li> <a href="/questions/8573070/php-exif-read-data-not-defined" dir="ltr">PHP:exif_read_data() not defined</a> <span class="question-originals-answer-count"> 3 answers </span> </li> </ul> </div> <p>I'm building a website that uses PHP to select all of the images from a folder to be displayed in a gallery. I also want the image <code>alt</code> tag to be the FileName of the photo's EXIF data - So I've developped this script:</p> <pre><code>&lt;?php $folder = 'cms/galleries/gallery-1/'; $filetype = '*.*'; $files = glob($folder.$filetype); foreach ($files as $file) { $filedata = exif_read_data($file[$i]); if(is_array($filedata) &amp;&amp; isset($filedata['FileName'])){ $filename = $filedata['FileName']; } else{ $filename = explode('.', basename($file[$i])); $filename = $filename[0]; } echo '&lt;div class="photoHolder"&gt;&lt;div class="photoCell"&gt;&lt;a class="fancybox" rel="group" href="'.$file.'"&gt;&lt;img class="photo" src="'.$file.'" alt="'.$filename.'"&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;'; } ?&gt; </code></pre> <p>The problem is I'm getting this error:</p> <blockquote> <p>Fatal error: Call to undefined function exif_read_data() in C:\AppServ\www\</p> </blockquote> <p>I have no idea what this means so can anyone help me with this or ruggest a few minor edits to get this up and running?</p> </div>

在移动设备上使用PHP上传图片时剥离GPS标题?

<div class="post-text" itemprop="text"> <p>I have a script to upload photos to a website written in PHP. When I upload a picture using Safari on my IPhone, some of the header appears to be stripped when I check the exif data. When I take the exact same picture from my IPhone and email it to myself and upload it from a computer, all of the exif data is there. </p> <p>I was wondering if there was a setting on the IPhone or a PHP script that I am missing that will let me grab the GPS part of the exif when I try to upload from my IPhone. All I want is to grab the GPS array from the exif_read_data when I upload pictures to my website through my IPhone.</p> <p>An Exif example from my Safari on Iphone:</p> <pre><code>Image type is: JPEG FILE.FileName: 20130417141031image.jpg FILE.FileDateTime: 1366225831 FILE.FileSize: 1692449 FILE.FileType: 2 FILE.MimeType: image/jpeg FILE.SectionsFound: ANY_TAG, IFD0, EXIF COMPUTED.html: width="3264" height="2448" COMPUTED.Height: 2448 COMPUTED.Width: 3264 COMPUTED.IsColor: 1 COMPUTED.ByteOrderMotorola: 1 IFD0.Orientation: 6 IFD0.Exif_IFD_Pointer: 38 EXIF.ColorSpace: 1 EXIF.ExifImageWidth: 3264 EXIF.ExifImageLength: 2448 </code></pre> <p>An Exif example of the same image uploaded from my PC taken by the same phone:</p> <pre><code>Image type is: JPEG FILE.FileName: 20130417142504image.jpeg FILE.FileDateTime: 1366226835 FILE.FileSize: 1744896 FILE.FileType: 2 FILE.MimeType: image/jpeg FILE.SectionsFound: ANY_TAG, IFD0, THUMBNAIL, EXIF, GPS COMPUTED.html: width="3264" height="2448" COMPUTED.Height: 2448 COMPUTED.Width: 3264 COMPUTED.IsColor: 1 COMPUTED.ByteOrderMotorola: 1 COMPUTED.ApertureFNumber: f/2.4 COMPUTED.Thumbnail.FileType: 2 COMPUTED.Thumbnail.MimeType: image/jpeg IFD0.Make: Apple IFD0.Model: iPhone 4S IFD0.Orientation: 6 IFD0.XResolution: 72/1 IFD0.YResolution: 72/1 IFD0.ResolutionUnit: 2 IFD0.Software: 6.1.3 IFD0.DateTime: 2013:04:17 15:13:39 IFD0.YCbCrPositioning: 1 IFD0.Exif_IFD_Pointer: 204 IFD0.GPS_IFD_Pointer: 594 THUMBNAIL.Compression: 6 THUMBNAIL.XResolution: 72/1 THUMBNAIL.YResolution: 72/1 THUMBNAIL.ResolutionUnit: 2 THUMBNAIL.JPEGInterchangeFormat: 890 THUMBNAIL.JPEGInterchangeFormatLength: 7684 EXIF.ExposureTime: 1/20 EXIF.FNumber: 12/5 EXIF.ExposureProgram: 2 EXIF.ISOSpeedRatings: 50 EXIF.ExifVersion: 0221 EXIF.DateTimeOriginal: 2013:04:17 15:13:39 EXIF.DateTimeDigitized: 2013:04:17 15:13:39 EXIF.ComponentsConfiguration: EXIF.ShutterSpeedValue: 2779/643 EXIF.ApertureValue: 4845/1918 EXIF.BrightnessValue: 13523/4727 EXIF.MeteringMode: 3 EXIF.Flash: 16 EXIF.FocalLength: 107/25 EXIF.SubjectLocation: Array EXIF.FlashPixVersion: 0100 EXIF.ColorSpace: 1 EXIF.ExifImageWidth: 3264 EXIF.ExifImageLength: 2448 EXIF.SensingMethod: 2 EXIF.ExposureMode: 0 EXIF.WhiteBalance: 0 EXIF.FocalLengthIn35mmFilm: 35 EXIF.SceneCaptureType: 0 GPS.GPSLatitudeRef: N GPS.GPSLatitude: Array GPS.GPSLongitudeRef: W GPS.GPSLongitude: Array GPS.GPSAltitudeRef: GPS.GPSAltitude: 55556/297 GPS.GPSTimeStamp: Array GPS.GPSImgDirectionRef: T GPS.GPSImgDirection: 19688/145 </code></pre> <p>Here is the code that I use for my PHP script for photos, I removed the header and requires:</p> <pre><code>&lt;?php require('[...]'); mysql_select_db($db_name, $oConn); $JobNum = $_POST['JobNum']; if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) &amp;&amp; ($_FILES["file"]["size"] &lt; 10000000)) { if ($_FILES["file"]["error"] &gt; 0) { ps_log( "Bad Photo Upload - Return Code: " . $_FILES["file"]["error"]); } else { ps_log( "Upload: " . $_FILES["file"]["name"]); ps_log( "Type: " . $_FILES["file"]["type"]); ps_log( "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb"); ps_log( "Temp file: " . $_FILES["file"]["tmp_name"] . "&lt;br /&gt;"); $photoname = $_FILES['file']['tmp_name']; $root = "[...]"; $location = $_SERVER['DOCUMENT_ROOT'].$root.$photoname; $exif = exif_read_data($photoname, 0, true); $filename = $exif["FILE"]["FileName"]; $model = $exif["IFD0"]["Model"]; $date = $exif["IFD0"]["DateTime"]; $lon = $exif["GPS"]["GPSLongitude"]; $lonref = $exif["GPS"]['GPSLongitudeRef']; $lat = $exif["GPS"]["GPSLatitude"]; $latref = $exif["GPS"]['GPSLatitudeRef']; $lon = Photos::getGps($lon, $lonref); $lat = Photos::getGps($lat, $latref); $photo = new UploadedPhoto(); $photo-&gt;JobNum = $JobNum; $photo-&gt;TempFile = $_FILES["file"]["tmp_name"]; $photo-&gt;FileName = $_FILES["file"]["name"]; $photo-&gt;Comments = $_POST['Comment']; $photo-&gt;Model = $model ; $photo-&gt;DateStamp = $date ; $photo-&gt;Lat = $lat ; $photo-&gt;Lng = $lon ; $photo-&gt;SaveGeo(); } } else { echo "Invalid file"; } header("[...]");?&gt; </code></pre> </div>

如何使用PHP从图像EXIF获取标题数据

<div class="post-text" itemprop="text"> <p>I have many images which have both the <code>title</code> attribute and the <code>description</code>.</p> <p>I'm able to get the description easily, but the title doesn't seem to be available in the EXIF data.</p> <p>Is there a different place where I can access the title from?</p> <p>I am accessing the <code>description</code> with the following:</p> <pre><code>$exif = exif_read_data($files['tmp_name'][$i]); $description = $exif['ImageDescription']; </code></pre> </div>

图像方向移动上传

<div class="post-text" itemprop="text"> <p>I am implementing an image upload function to use the mobile phone camera. It is working fine, but the photos are always rotated wrong.</p> <p>I did read about using the php function exif_read_data. I found codes how to use it and how to change the orientation and how to save it again. Now my problem is (using Android) that the exif_read_data array does not contain any "Orientation", so I am not able to change the orientation. I can not find any hints or posts about this problem. Why is my orientation not stored in this array?</p> <p>Thanks for any help</p> </div>

在PHP CodeIgniter中读取EXIF

<div class="post-text" itemprop="text"> <p>I'm making an API in PHP using CodeIgniter. I need to save the data and the image given. Here's the API Documentation : <a href="https://i.stack.imgur.com/1creP.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1creP.jpg" alt="enter image description here"></a></p> <p>I already got the data using $_POST['data']. But for the image I can't get it with $_FILES. I know images should be retrieved with $_FILES. But the client somehow don't put it as a file. He put the binary data of the file in a POST Body instead. Instead of sending me the image, he sent me this data.</p> <p>This is my code for getting the data.</p> <pre><code>$data = json_decode($_POST['data']); $image = $_POST['image']; </code></pre> <p>The binary data starts with this snippet</p> <pre><code>ExifMM*n%&lt;i2vRedmi 32019:07:24 20:10:31Xiaomi !5'|A'4557864557862019:07:24 20:10:31455786fqx2019:07:24200/100 JFIFC </code></pre> <p>I think this is an EXIF file. Can anybody confirm it? I'm not really familiar with file type. I already tried using exif_read_data, but error shows file not supported.</p> <p>Is there anyway of getting an image from such file? If I can get the data using EXIF then why does PHP said the file is not supported. Any help would be greatly appreciated.</p> </div>

Wamp服务器为PHP应用补丁

<div class="post-text" itemprop="text"> <p>I am using WAMP server version 3.1.4 64 bit, having PHP version 7.2.10, Apache version 2.4.35,</p> <p>There are <strong>Multiple Heap Buffer Overflow Vulnerabilities</strong> for PHP versions prior to 7.3.3.</p> <p>Vulnerabilities listed <a href="https://www.securityfocus.com/bid/107794/discuss" rel="nofollow noreferrer">here</a> </p> <p>and patch for the Vulnerability available <a href="https://bugs.php.net/bug.php?id=77753" rel="nofollow noreferrer">here</a> </p> <p>Possible solution is i can download latest Wamp server(Which provide PHP version 7.3.4) and install it, but here is catch, my some of the applications requires SSH access to other remote server to run scripts on remote servers and some applications also requierd SFTP connections to remote servers,You can check <a href="https://windows.php.net/downloads/pecl/releases/ssh2/1.1.2/" rel="nofollow noreferrer">here</a> that php_ssh2.dll,php_ssh2.pdb is only available for PHP verion 7.2, not for PHP version 7.3, so if i upgrade WAMP server to latest verion, These applications will stop working, So i have to apply patch available to provide audit compliance.</p> <p>I dont know how to apply these patch and also not able to find any article which helps/guide me for the same. </p> <p>Link of patch posted above and i am also mentioning content of patch file below </p> <pre><code>diff --git a/ext/exif/exif.c b/ext/exif/exif.c index fe89b85471..0b5bb5ae21 100644 --- a/ext/exif/exif.c +++ b/ext/exif/exif.c @@ -2802,6 +2802,10 @@ static int exif_process_IFD_in_MAKERNOTE(image_info_type *ImageInfo, char * valu exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD size: 2 + 0x%04X*12 = 0x%04X &gt; 0x%04X", NumDirEntries, 2+NumDirEntries*12, value_len); return FALSE; } + if ((dir_start - value_ptr) &gt; value_len - (2+NumDirEntries*12)) { + exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD size: 0x%04X &gt; 0x%04X", (dir_start - value_ptr) + (2+NumDirEntries*12), value_len); + return FALSE; + } for (de=0;de&lt;NumDirEntries;de++) { if (!exif_process_IFD_TAG(ImageInfo, dir_start + 2 + 12 * de, </code></pre> <p>Can anyone help me with how can i apply this patch ?</p> </div>

如何根据EXIF'方向'数据停止PHP iMagick自动旋转图像

<div class="post-text" itemprop="text"> <p>Currently working with PHP and iMagick to develop a poster printing Web application.</p> <p>This is the example image I am using to test upload/image editing features of the application:</p> <p><img src="https://i.stack.imgur.com/i8SP8.png" alt="alt text"></p> <p>The image contains the following EXIF data:</p> <pre><code>[FileName] =&gt; 1290599108_IMG_6783.JPG [FileDateTime] =&gt; 1290599109 [FileSize] =&gt; 4275563 [FileType] =&gt; 2 [MimeType] =&gt; image/jpeg [SectionsFound] =&gt; ANY_TAG, IFD0, THUMBNAIL, EXIF, INTEROP, MAKERNOTE [COMPUTED] =&gt; Array ( [html] =&gt; width="3504" height="2336" [Height] =&gt; 2336 [Width] =&gt; 3504 [IsColor] =&gt; 1 [ByteOrderMotorola] =&gt; 0 [CCDWidth] =&gt; 22mm [ApertureFNumber] =&gt; f/5.6 [UserComment] =&gt; [UserCommentEncoding] =&gt; UNDEFINED [Thumbnail.FileType] =&gt; 2 [Thumbnail.MimeType] =&gt; image/jpeg ) [Make] =&gt; Canon [Model] =&gt; Canon EOS 30D [Orientation] =&gt; 6 [XResolution] =&gt; 72/1 [YResolution] =&gt; 72/1 [ResolutionUnit] =&gt; 2 [DateTime] =&gt; 2009:08:31 08:23:49 [YCbCrPositioning] =&gt; 2 [Exif_IFD_Pointer] =&gt; 196 </code></pre> <p>However - iMagick, when __construct'ed with this image, automatically rotates it an additional 90 degrees CCW as per <code>[Orientation] =&gt; 6</code> (I think!). Resulting in this...</p> <p><img src="https://i.stack.imgur.com/5F6qd.jpg" alt="alt text"></p> <p>What I'd like to know is...</p> <p>How can I maintain the original orientation of the image seen at the top of the page? And is this possible through disabling the auto-rotation performed by iMagick?</p> <p>Many thanks</p> <p><strong>UPDATE: Here's the solution I've come up with... It will fix the orientation based on the orientation in the EXIF data</strong></p> <pre><code> public function fixOrientation() { $exif = exif_read_data($this-&gt;imgSrc); $orientation = $exif['Orientation']; switch($orientation) { case 6: // rotate 90 degrees CW $this-&gt;image-&gt;rotateimage("#FFF", 90); break; case 8: // rotate 90 degrees CCW $this-&gt;image-&gt;rotateimage("#FFF", -90); break; } } </code></pre> </div>

提取显示“数组”的EXIF数据

<div class="post-text" itemprop="text"> <p>Trying to extract the location data from a photo exif, but it's only showing 'Array' for the GPS data. It needs to save the data to a log file on a server for scraping. Am I doing something wrong? The photo definitely has geolocation data on it.</p> <pre><code>&lt;?php $image = "narnia.jpg"; $exif = exif_read_data($image, 0, true); foreach ($exif as $key =&gt; $section) { foreach ($section as $name =&gt; $val) { echo "$key.$name: $val&lt;pre&gt; &lt;/pre&gt;"; } } ?&gt; GPS.GPSLatitudeRef: N GPS.GPSLatitude: Array GPS.GPSLongitudeRef: W GPS.GPSLongitude: Array GPS.GPSTimeStamp: Array </code></pre> </div>

如果能重来,我不会选择北漂——初见北京

一个人走的路

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

我说我不会算法,阿里把我挂了。

不说了,字节跳动也反手把我挂了。

2020年大厂Java面试前复习的正确姿势(800+面试题答案解析)

前言 个人觉得面试也像是一场全新的征程,失败和胜利都是平常之事。所以,劝各位不要因为面试失败而灰心、 丧失斗志。也不要因为面试通过而沾沾自喜,等待你的将是更美好的未来,继续加油! 本篇分享的面试题内容包括:Java、MyBatis、ZooKeeper、Dubbo、Elasticsearch、Redis、MySQL、Spring、SpringBoot、SpringCloud、RabbitMQ...

抖音上很火的时钟效果

反正,我的抖音没人看,别人都有几十万个赞什么的。 发到CSDN上来,大家交流下~ 主要用到原生态的 JS+CSS3。 具体不解释了,看注释: &lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;title&gt;Title&lt;/tit...

记录下入职中软一个月(外包华为)

我在年前从上一家公司离职,没想到过年期间疫情爆发,我也被困在家里,在家呆着的日子让人很焦躁,于是我疯狂的投简历,看面试题,希望可以进大公司去看看。 我也有幸面试了我觉得还挺大的公司的(虽然不是bat之类的大厂,但是作为一名二本计算机专业刚毕业的大学生bat那些大厂我连投简历的勇气都没有),最后选择了中软,我知道这是一家外包公司,待遇各方面甚至不如我的上一家公司,但是对我而言这可是外包华为,能...

又出事了?网站被攻击了?高中生?

北京时间2020年3月27日9点整,如往常一样来到公司,带开电脑,正准备打开Github网站看一会源代码,再开始手头的工作。哟吼,一直打不开,一直出现如下页面: 我想很多网友也尝到了甜头,各大技术群炸开了锅,据网友反馈有攻击者正在发起大规模的中间人挟持,京东和Github等网站等网站都受到了影响。 什么是中间中间人挟持呢? 简而言之,就是攻击者在数据网络传输的过程中,截获传输过程中的数据并篡改...

培训班出来的人后来都怎么样了?(二)

接着上回说,培训班学习生涯结束了。后面每天就是无休止的背面试题,不是没有头脑的背,培训公司还是有方法的,现在回想当时背的面试题好像都用上了,也被问到了。回头找找面试题,当时都是打印下来天天看,天天背。 不理解呢也要背,面试造飞机,上班拧螺丝。班里的同学开始四处投简历面试了,很快就有面试成功的,刚开始一个,然后越来越多。不知道是什么原因,尝到胜利果实的童鞋,不满足于自己通过的公司,嫌薪水要少了,选择...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

工作八年,月薪60K,裸辞两个月,投简历投到怀疑人生!

近日,有网友在某职场社交平台吐槽,自己裸辞两个月了,但是找工作却让自己的心态都要崩溃了,全部无果,不是已查看无回音,就是已查看不符合。 “工作八年,两年一跳,裸辞两个月了,之前月薪60K,最近找工作找的心态崩了!所有招聘工具都用了,全部无果,不是已查看无回音,就是已查看不符合。进头条,滴滴之类的大厂很难吗???!!!投简历投的开始怀疑人生了!希望 可以收到大厂offer” 先来看看网...

我把华为小米年报放一起,发现华为才是真·手机公司,小米确实不靠卖手机赚钱...

郭一璞 发自 凹非寺量子位 报道 | 公众号 QbitAI国产手机界的两大玩家,华为&amp;小米,昨天在同一天前后脚发布了2019年财报。同行冤家,发财报也碰在了同一天。那我们就对比...

大牛都会用的IDEA调试技巧!!!

导读 前天面试了一个985高校的实习生,问了他平时用什么开发工具,他想也没想的说IDEA,于是我抛砖引玉的问了一下IDEA的调试用过吧,你说说怎么设置断点...

97年世界黑客编程大赛冠军作品(大小仅为16KB),惊艳世界的编程巨作

这是世界编程大赛第一名作品(97年Mekka ’97 4K Intro比赛)汇编语言所写。 整个文件只有4095个字节, 大小仅仅为16KB! 不仅实现了3D动画的效果!还有一段震撼人心的背景音乐!!! 内容无法以言语形容,实在太强大! 下面是代码,具体操作看最后! @echo off more +1 %~s0|debug e100 33 f6 bf 0 20 b5 10 f3 a5...

不要再到处使用 === 了

我们知道现在的开发人员都使用 === 来代替 ==,为什么呢?我在网上看到的大多数教程都认为,要预测 JavaScript 强制转换是如何工作这太复杂了,因此建议总是使用===。这些都...

什么是a站、b站、c站、d站、e站、f站、g站、h站、i站、j站、k站、l站、m站、n站?00后的世界我不懂!

A站 AcFun弹幕视频网,简称“A站”,成立于2007年6月,取意于Anime Comic Fun,是中国大陆第一家弹幕视频网站。A站以视频为载体,逐步发展出基于原生内容二次创作的完整生态,拥有高质量互动弹幕,是中国弹幕文化的发源地;拥有大量超粘性的用户群体,产生输出了金坷垃、鬼畜全明星、我的滑板鞋、小苹果等大量网络流行文化,也是中国二次元文化的发源地。 B站 全称“哔哩哔哩(bilibili...

十个摸鱼,哦,不对,是炫酷(可以玩一整天)的网站!!!

文章目录前言正文**1、Kaspersky Cyberthreat real-time map****2、Finding Home****3、Silk – Interactive Generative Art****4、Liquid Particles 3D****5、WINDOWS93****6、Staggering Beauty****7、Ostagram图片生成器网址****8、全历史网址*...

终于,月薪过5万了!

来看几个问题想不想月薪超过5万?想不想进入公司架构组?想不想成为项目组的负责人?想不想成为spring的高手,超越99%的对手?那么本文内容是你必须要掌握的。本文主要详解bean的生命...

毕业5年,我熬夜整理出了这50个优质的电子书网站,吐血推荐!

大家好,我是武哥,最近经常有小伙伴问我要电子书,都什么年代了,还找不到电子书吗?如果要说原因,那就是你还没遇到武哥我(手动滑稽~)!我今天把这么多年我经常看的电子书网站整理一下给大家,基本上能解决大家的需求。不管是在校生还是已经工作了,相信肯定对你有所帮助! 1.鸠摩搜书 首先给大家推荐的网站是:鸠摩搜书 地址:https://www.jiumodiary.com/ 这个网上非常棒,上面有很多优质...

MySQL性能优化(五):为什么查询速度这么慢

前期回顾: MySQL性能优化(一):MySQL架构与核心问题 MySQL性能优化(二):选择优化的数据类型 MySQL性能优化(三):深入理解索引的这点事 MySQL性能优化(四):如何高效正确的使用索引 前面章节我们介绍了如何选择优化的数据类型、如何高效的使用索引,这些对于高性能的MySQL来说是必不可少的。但这些还完全不够,还需要合理的设计查询。如果查询写的很糟糕,即使表结构再合理、索引再...

大厂的 404 页面都长啥样?最后一个笑了...

每天浏览各大网站,难免会碰到404页面啊。你注意过404页面么?猿妹搜罗来了下面这些知名网站的404页面,以供大家欣赏,看看哪个网站更有创意: 正在上传…重新上传取消 腾讯 正在上传…重新上传取消 网易 淘宝 百度 新浪微博 正在上传…重新上传取消 新浪 京东 优酷 腾讯视频 搜...

自从喜欢上了B站这12个UP主,我越来越觉得自己是个废柴了!

不怕告诉你,我自从喜欢上了这12个UP主,哔哩哔哩成为了我手机上最耗电的软件,几乎每天都会看,可是吧,看的越多,我就越觉得自己是个废柴,唉,老天不公啊,不信你看看…… 间接性踌躇满志,持续性混吃等死,都是因为你们……但是,自己的学习力在慢慢变强,这是不容忽视的,推荐给你们! 都说B站是个宝,可是有人不会挖啊,没事,今天咱挖好的送你一箩筐,首先啊,我在B站上最喜欢看这个家伙的视频了,为啥 ,咱撇...

代码注释如此沙雕,会玩还是你们程序员!

某站后端代码被“开源”,同时刷遍全网的,还有代码里的那些神注释。 我们这才知道,原来程序员个个都是段子手;这么多年来,我们也走过了他们的无数套路… 首先,产品经理,是永远永远吐槽不完的!网友的评论也非常扎心,说看这些代码就像在阅读程序员的日记,每一页都写满了对产品经理的恨。 然后,也要发出直击灵魂的质问:你是尊贵的付费大会员吗? 这不禁让人想起之前某音乐app的穷逼Vip,果然,穷逼在哪里都是...

总结了Mybatis,原来知识点也没多少嘛

看完这篇Mybatis,感觉你三天就会用了。

爬虫(101)爬点重口味的

小弟最近在学校无聊的很哪,浏览网页突然看到一张图片,都快流鼻血。。。然后小弟冥思苦想,得干一点有趣的事情python 爬虫库安装https://s.taobao.com/api?_ks...

疫情后北上广深租房价格跌了吗? | Alfred数据室

去年3月份我们发布了《北上广深租房图鉴》(点击阅读),细数了北上广深租房的各种因素对租房价格的影响。一年过去了,在面临新冠疫情的后续影响、城市尚未完全恢复正常运转、学校还没开学等情况下...

面试官给我挖坑:a[i][j] 和 a[j][i] 有什么区别?

点击上方“朱小厮的博客”,选择“设为星标”后台回复&#34;1024&#34;领取公众号专属资料本文以一个简单的程序开头——数组赋值:int LEN = 10000; int[][] ...

在拼多多上班,是一种什么样的体验?我心态崩了呀!

之前有很多读者咨询我:武哥,在拼多多上班是一种什么样的体验?由于一直很忙,没抽出时间来和大家分享。上周末特地花点时间来写了一篇文章,跟大家分享一下拼多多的日常。 1. 倒时差的作息 可能很多小伙伴都听说了,拼多多加班很严重。这怎么说呢?作息上确实和其他公司有点区别,大家知道 996,那么自然也就能理解拼多多的“11 11 6”了。 所以当很多小伙伴早上出门时,他们是这样的: 我们是这样的: 当...

相关热词 c# 局部 截图 页面 c#实现简单的文件管理器 c# where c# 取文件夹路径 c# 对比 当天 c# fir 滤波器 c# 和站 队列 c# txt 去空格 c#移除其他类事件 c# 自动截屏
立即提问