bonjour
J'utilise un script php qui lit une directory de fichiers jpeg
pour creer 2 composant une mini et une visu puis extrait des metas data-iptc le voici:
<?
require ("config.inc.php");
require("ftp.php");
require("conchita.php");
//require("purge.inc.php");
require("dreamfake.php");
/* connexion à la base de donnees ------------------------------------------- */
$db = mysql_connect("$host", "$login", "$password") or die("Impossible de se connecter : " . mysql_error());
mysql_select_db("$base",$db);
$rep2=opendir("minis/");
$rep=opendir("photos/");
$rep3=opendir("visu/");
//$rep4=opendir("meres/");
while ($nom=readdir($rep))
{
if (!ereg("^\.(jpg),^\.(JPEG),^\.(JPG),^\.(jpeg)",$nom) and (!file_exists("minis/$nom")and (!file_exists("visu/$nom"))))
{
$tb[]=$nom;
$nom2="photos/".$nom;
$handle = imagecreatefromjpeg($nom2);
$handle2 = imagecreatefromjpeg($nom2);
$x=imagesx($handle);
$y=imagesy($handle);
$x2=imagesx($handle2);
$y2=imagesy($handle2);
$k=$x/200;
$k2=$x2/400;
$y_dest=$y/$k;
$y_dest2=$y2/$k2;
$dst_img = imagecreatetruecolor(200,$y_dest);
$dst_img2 = imagecreatetruecolor(400,$y_dest2);
imagecopyresampled($dst_img, $handle, 0, 0, 0, 0, 200, $y_dest, $x, $y);
imagecopyresampled($dst_img2, $handle2, 0, 0, 0, 0, 400, $y_dest2, $x2, $y2);
imagejpeg($dst_img, "minis/$nom",100);
imagejpeg($dst_img2, "visu/$nom",100);
imagedestroy($handle);
imagedestroy($handle2);
imagedestroy($dst_img);
imagedestroy($dst_img2);
//copy($nom2,"meres/$nom");
foreach ($tb as $valeur)
/*extraction et lecture des champs iptc-----------------------------------------------*/
$size = GetImageSize("photos/$valeur",&$info);
if (isset($info["APP13"])) {
$iptc = iptcparse($info["APP13"]);}
if (is_array($iptc)) {
$result1["caption"] = $iptc["2#120"][0];
$result2["object_name"] = $iptc["2#005"][0];
$result3["urgency"] = $iptc["2#010"][0];
$result4["category"] = $iptc["2#015"][0];
$result5["supp_categories"] = $iptc["2#020"][0];
$result6["spec_instr"] = $iptc["2#040"][0];
$result7["release_date"] = $iptc["2#030"][0];
$result30["release_time"] = $iptc["2#035"][0];
$result8["by_line"] = $iptc["2#080"][0];
$result9["byline_title"] = $iptc["2#085"][0];
$result10["city"] = $iptc["2#090"][0];
$result11["state"] = $iptc["2#095"][0];
$result12["country"] = $iptc["2#101"][0];
$result13["otr"] = $iptc["2#103"][0];
$result14["headline"] = $iptc["2#105"][0];
$result15["credit"] = $iptc["2#110"][0];
$result16["source"] = $iptc["2#115"][0];
$result18["keywords"] = $iptc["2#025"][0];
$result19["caption_writer"] = $iptc["2#122"][0];
$result20["service"] = $iptc["1#030"][0];
$result21["date_created"] = $iptc["2#055"][0];
$result22["langue"] = $iptc["2#135"][0];
$result23["copyr"] = $iptc["2#116"][0];
$result24["time_created"] = $iptc["2#060"][0];
$result25["cpays"] = $iptc["2#100"][0];
$result26["cville"] = $iptc["2#240"][0];
$result32["logiciel"] = $iptc["2#065"][0];
$result33["version"] = $iptc["2#070"][0];
$result34["date_sent"] = $iptc["1#070"][0];
$result35["time_sent"] = $iptc["1#080"][0];
$caption=$result1["caption"];
$supcat=$result5["supp_categories"];
$object_name=$result2["object_name"];
$category=$result4["category"];
$speinstr=$result6["spec_instr"];
$by_line= $result8["by_line"];
$byline_title=$result9["byline_title"];
$otr= $result13["otr"];
$headline=$result14["headline"];
$credit=$result15["credit"];
$source=$result16["source"];
$keyword=$result18["keywords"];
$capw=$result19["caption_writer"];
$service=$result20["service"];
$lng=$result22["langue"];
$copyr=$result23["copyr"];
$cpays=$result25["cpays"];
$cville=$result26["cville"];
$release_date=$result7["release_date"];
$release_time=$result30["release_time"];
$date_created=$result21["date_created"];
$time_created=$result24["time_created"];
$city=$result10["city"];
$date_sent=$result34["date_sent"];
$time_sent=$result35["time_sent"];
/* Formatage du texte pour base mysql----------*/
$caption=addslashes(stripslashes(trim($caption)));
$caption=addslashes(stripslashes(strtolower(trim($caption))));
$caption=htmlspecialchars($caption);
$caption=ucfirst($caption);
$city=addslashes(stripslashes(trim($city)));
$city=addslashes(stripslashes(strtoupper(trim($city))));
$city=htmlspecialchars($city);
$object_name=addslashes(stripslashes(strtoupper(trim($object_name))));
$object_name=addslashes(stripslashes(trim($object_name)));
$object_name=htmlspecialchars($object_name);
$keyword=htmlspecialchars($keyword);
$keyword=addslashes(stripslashes(trim($keyword)));
$headline=htmlspecialchars($headline);
$headline=addslashes(stripslashes(trim($headline)));
$capw=htmlspecialchars($capw);
$capw=addslashes(stripslashes(trim($capw)));
$supcat=htmlspecialchars($supcat);
$supcat=addslashes(stripslashes(trim($supcat)));
$speinstr=htmlspecialchars($speinstr);
$speinstr=addslashes(stripslashes(trim($speinstr)));
$source=strtoupper($source);
$state=$result11["state"];
$state=htmlspecialchars($state);
$state=addslashes(stripslashes(trim($state)));
$country=$result12["country"];
$country=htmlspecialchars($country);
$country=addslashes(stripslashes(trim($country)));
$urgency=$result3["urgency"];
/* envoie de la requete au serveur MYSQL ----------------------------------------*/
$sql=MYSQL_QUERY("INSERT INTO `iptc` (`Ref_pho`,`caption`,`object_name`,`urgency`,`category`,`supp_categories`,`spec_instr`,`release_date`,`by_line`,`byline_title`,`city`,`state`,`country`,`otr`,`headline`,`credit`,`source`,`keywords`,`caption_writer`,`service`,`date_created`,`langue`,`copyr`,`time_created`,`cpays`,`cville`,`nom_fich`,`time_created_gmt`,`release_time`,`release_time_gmt`,`date_sent`,`time_sent`)
VALUES ('', '$caption','$object_name','$urgency', '$category', ' $supcat', '$speinstr', '$release_date' , '$by_line', '$byline_title', '$city', '$state', '$country', '$otr', '$headline', '$credit', '$source', '$keyword', '$capw', '$service', '$date_created' , '$lng', '$copyr', '$time_created', '$cpays', '$cville','$valeur', '$time_created','$release_time','$release_time','$date_sent','$time_sent')");
mysql_query("DELETE FROM iptc where nom_fich='Thumbs.db'"); /* a cause de la grosse DAUBE Microsoft qui cree ce fichier pour ses miniatures---*/
}
}
}
/* fin de boucle *------------------------------*/
while ($nom=readdir($rep2))
{
if (file_exists("minis/$nom") and !file_exists("photos/$nom"))
{
unlink("minis/$nom");
}
}
while ($nom=readdir($rep3))
{
if (file_exists("visu/$nom") and !file_exists("photos/$nom"))
{
mysql_query("DELETE from iptc where nom_fich='$nom'");
unlink("visu/$nom");
}
}
MYSQL_CLOSE();
?>
Mais j'ai un petit probleme lorque qu'un fichier jpeg est corrompu
car il est traite quand meme et je voudrais savoir si il ya moyen
de verifier l'intergritee d'un fichier avec readfile ou fread
savoir si le fichier jpeg a une fin correcte ou pas
Merci