当前位置:首页> PHP教程> PHP精通
关键字
文章内容
如何用 php 从 .jpg 图像中读取 exif
 
 
修改时间:[2009/05/14 20:33]    阅读次数:[977]    发表者:[起缘]
 
read_exif_data
(PHP 4 )

read_exif_data -- Reads header information stored in TIFF and JPEG images
Description
array exif_read_data ( string filename, string sections, bool arrays, bool thumbnail)


Note: The read_exif_data() function is an alias for exif_read_data().

See also exif_thumbnail().

User Contributed Notes
read_exif_data
[email protected]
03-Jan-2001 03:52

Each of my jpeg files are over 1 meg, and read_exif_data seems to read the
whole file and it's very slow. So I wrote a function to read only the
beginning of each file:

function read_exif_data_quick($path) {
$tmpfile = "/tmp/read_exif_data_quick.tmp_file";
$in = fopen($path, "r");
$out = fopen($tmpfile,"w");
fwrite( $out, fread( $in, 15000 ) );
fclose($in);
fclose($out);
return read_exif_data($tmpfile);
}

And so far it works for all of my jpegs (taken with my digital camera).



[email protected]
06-Jul-2001 05:33

I started drooling when I saw that php could read the exif information
automatically for me. Then I found out that read_exif_data is NOT
compiled into the standard win32 build (think about including it please!).
To get around this I found the following program that runs from the
command line and works really well.
it's actually a set of utilities that will even allow you to put exif data
into images.

It's freeware, but the license says no commercial use without written
permission.


http://www.users.bigpond.com/hughthomas/exif.html



[email protected]
06-Jul-2001 05:34

By the way, it works under linux or win32



[email protected]
21-Aug-2001 11:43

Perl Image::Info module is capable of reading EXIF tags (places them into
an associative array). You can write a simple script to use the module and
it will extract all or only required tags out of a jpeg file.



[email protected]
12-Sep-2001 07:54

This is a slight modification of the example1 script at the top. It works
at least with Canon Digital Ixus and writes out the thumbnail as a picture
instead of the code.

$adress="IMG_XXX.JPG";
$exif = read_exif_data ($adress);
while(list($k,$v)=each($exif)) {
if($k=="Thumbnail"){
$fp=fopen ("/www/home/image/Thumbnail$adress",
'a');
fwrite ($fp, $v);
fclose ($fp);
echo "<br />\n";
echo "\n";
echo "<br />\n";
}else{
echo "$k: $v<br />\n";
}
}

来源:www.php.net