getting image height and width from zipped files
getNameIndex($i)I am currently using the zip archive function to extract some images, I am looking for a method which gives the filepath of each individual image so I can use getimagesize to get the width and height, below is the method am using to loop through the files.
$chapterZip = new ZipArchive();
if ($chapterZip->open($_FILES['chapterUpload']['tmp_name']))
{
for($i = 0; $i < $chapterZip->numFiles; 开发者_开发知识库$i++) {
list($width, $height) = getimagesize(getNameIndex($i));
$imageLocation= "INSERT INTO imageLocation (imageLocation,imageWidth,imageHeight,chapterID) VALUES ('"."Manga/".$_POST['mangaName']."/".$_POST['chapterName']."/".$chapterZip->getNameIndex($i)."',".$width.",".$height.",".$chapterID.")";
getQuery($imageLocation,$l);
}
if($chapterZip->extractTo("Manga/".$_POST['mangaName']."/".$_POST['chapterName']))
{
$errmsg0.="You have successfully uploaded a manga chapter";
$chapterZip->close();
}
}
any help with this would be greatly appreciated !
With PHP's Zip extension's stream wrapper, do not have to manually extract all files:
$size = getimagesize('zip:///path/to/file.zip#path/to/image.jpg');
精彩评论