如何用 php 从 .jpg 图像中读取 exif

 更新时间:2016年11月25日 16:33  点击:2113
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
inq@inq.dhs.org
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).
garbage@sunflowerroad.com
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
garbage@sunflowerroad.com
06-Jul-2001 05:34
By the way, it works under linux or win32
ibaldin@anr.mcnc.org
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.
Compiling php with crypt()
author:
Daniel Beulshausen
updated:
14.10.2000


This quick tutorial shall help you to compile php with support for the crypt() function, because it's not correct that if you use windows you can't use crypt().
It is however correct that libcrypt isn't available by default on windows, but you can use the libary from our download section.
Extract the zip and move crypt.h to your include folder, and the needed libary (release or debug) to your libary folder (tools -> options -> folders).
Load the php workspace, and add crypt.c (can be found in ext/standard/) to the php4dllts group (you can put crypt.c to Function Modules -> Source Files).
Now edit the link options of the php4dllts project, and add libcrypt to the link libaries, note that we compiled a release and a debug libary, please use only release for the release builds, and the debug libary for debug builds!
Now edit config.w32.h (located in main/), edit it and change the needed defines:
#define HAVE_CRYPT 1
#define HAVE_CRYPT_H 1
This should do the trick, and it'll build you php with the crypt() function. 
作 者: 徐永久
我们知道 Zend 有免费的优化引擎针对 PHP 而作,但是 FreeLAMP 这次采用的是一个叫做 PHP Accelerator 的缓冲产品。
我们在 “LAMP 加速” 这篇文章中阐述过加速的几种办法,其中提到了 PHP Accelerator,它的安装方法十分简单,但是需要去他的网站获取一个激活键。
一、下载:
http://www.php-accelerator.co.uk/download.php
二、获取激活键并安装:
http://www.php-accelerator.co.uk/activate.php
注册自己的 SERVER_NAME 后,你会得到下面的提示:
Your key for www.freelamp.com is 8edfd13946c96309244fcca309415902
Now you must set the key for www.freelamp.com in your site configuration.
For single domains not using virtual hosts
The key can be set in the php.ini file as follows:
# PHPA key for www.freelamp.com
#
phpa.registration_key = 8edfd13946c96309244fcca309415902
For domains setup as a virtual host
Add the key to the domain specific section for your web server.
# www.freelamp.com VHost entry
#
ServerName www.freelamp.com
# ... (other vhost specific config)
# php settings
php_value phpa.registration_key 8edfd13946c96309244fcca309415902
# also enable phpa if set to off in the php.ini (the default is on)
php_value phpa 1
具体的 phpa 值的设置,可以参考软件随带的 CONFIGURATION 文件的配置。
由于大多数网站是虚拟主机配置,所以,建议采用 php_value phpa. 的方式设置。
例如:
php_value phpa.tweaks off
php_value phpa.cache_dir /tmp
php_value phpa.file_perms 400
php_value phpa.ignore_files "/index.php, /a/test.php"
# php_value phpa.ignore_dirs "/data/WWW/site1/,/cache/"
php_value phpa.shm_size 8
php_value phpa.shm_key 0xc0deb00
php_value phpa.shm_perms 664
三、设置 php.ini
假设我们把下载后的文件解开到 /usr/local/php ,那么在 php.ini 中加入:
zend_extension=/usr/local/php/php_accelerator_1.2p2.so
并注释掉原来的 Zend 优化引擎:
# zend_extension=/usr/local/Zend/lib/ZendOptimizer.so
最近在用PHP作一社区, 在写到计算最高上线人数时, 成功调试出把PHP作为shell script直接在服务器上运行.
在作社区时, 时常需要统计上线人数等数据. 一般做法是, 把这段代码放在用户login或者某一个页面中, 以便在用户登录或访问到该时,触发运行该代码. 这样一来, 会造成一个问题, 如果该代码教复杂, 明显减慢该页的正常调用速度.
利用PHP 的这种特性,加上linux的crontab指令,即可自动定时执行某一个php文件(统计在线人数等).
具体方法:
在安装PHP的时候,会产生一个可执行文件,文件名为php.将它它 copy 到 /usr/local/bin 下.
在终端方式执行php程序: php -q onlinnum.php<Enter>
注意到 PHP 原本是应用在网页应用的╋因此它内定会送出 HTML 的 HEADER╋但是在此我们是要将 PHP 用作 Shell Script╋"-q" 就是表示不要送出 HEADER 的意思.你可以试试看不加上 -q 的显示结果。
此时你已经可以在终端方式下执行PHP 代码了. 呵呵,可以试试执行你以前写的代码.
linux命令:cron daemon
这是一个系统中常驻的服务,功能在于执行例行性的工作,如每天一次或每月一次检查磁盘。cron daemon 会在每分钟检查一次排定的工作表(crontab),看看是否有要执行的指令,所有的输出会以mail寄给用户。
设置 crontab
命令:crontab -e<Enter>
该命令呼叫vi编辑器来编辑执行的清单。例如
            0 0 1,15 * * fsck /home
            1 * * * * /home/Gull/onlinnumber
每一行代表一项排定的工作,在指令前为排定的时间,总共有5个栏位,以空格间隔,由左到右依序如下:
       栏位        说明
        --------------------------
       分钟       从00到99
       点钟       从0到24
       日       从01到31
       月       从01到12
初步认识邮件的源文件
  本文简要说明了通过POP3协议收取邮件、MIME邮件的解码的原理;针对收取和MIME解码,提供了两个实用的PHP类,并提供了使用的样例。分为邮件收取、MIME解码两个部分。我们已经向您介绍过了邮件的收取,现在让我们来为您介绍本文的解码部。
  在上一篇里,我们已经完成了一个用PHP通过POP3收取邮件的实例,可是在使用这个类的时候,相信你已经看到了,很多的邮件收下来是一堆乱码,自己根本看不懂!是的。现在的邮件大部分都已经经过了编码,需要一个解码的过程才能变成我们习惯的文字、图片、或是其它的附件。
  邮件的源文件
  首先,我们来看一段简单的邮件的源文件:(在Foxmail中,选中邮件,点选“查看源文件”就会看到这样的些内容了)
  From:
  To:
  Subject: =?gb2312?B?xOO6w6Oh?=
  Date: Sun, 8 Oct 2000 20:28:45 +0800
  MIME-Version: 1.0
  Content-Type: multipart/alternative;
   boundary="----=_NextPart_000_0007_01C03166.5B1E9510"
  X-Priority: 3
  X-MSMail-Priority: Normal
  X-Mailer: Microsoft Outlook Express 5.00.2919.6700
  X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700
  This is a multi-part message in MIME format.
  ------=_NextPart_000_0007_01C03166.5B1E9510
  Content-Type: text/plain;
   charset="gb2312"
  Content-Transfer-Encoding: base64
  w7vT0MLSwuuwyaO/DQo=
  ------=_NextPart_000_0007_01C03166.5B1E9510
  Content-Type: text/html;
   charset="gb2312"
  Content-Transfer-Encoding: base64
  PCFET0NUWVBFIEhUTUwgUFVCTElDICItLy9XM0MvL0RURCBIVE1MIDQuMCBUcmFuc2l0aW9uYWwv
  L0VOIj4NCjxIVE1MPjxIRUFEPg0KPE1FVEEgY29udGVudD0idGV4dC9odG1sOyBjaGFyc2V0PWdi
  MjMxMiIgaHR0cC1lcXVpdj1Db250ZW50LVR5cGU+DQo8TUVUQSBjb250ZW50PSJNU0hUTUwgNS4w
  MC4yOTIwLjAiIG5hbWU9R0VORVJBVE9SPg0KPFNUWUxFPjwvU1RZTEU+DQo8L0hFQUQ+DQo8Qk9E
  WSBiZ0NvbG9yPSNmZmZmZmY+DQo8RElWPjxGT05UIHNpemU9Mj7Du9PQwtLC67DJo788L0ZPTlQ+
  PC9ESVY+PC9CT0RZPjwvSFRNTD4NCg==
[!--infotagslink--]

相关文章