Getting height and width of an image from zip files

getNameIndex ($ i) I am currently using the zip archive function to extract some images, I am looking for a method that gives the file path of each individual image, so I can use getimagesize to get the width and height, below the am method, which uses to scroll 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!

+1
php zip
source share
1 answer

With the Stream Zip extension, you do not need to manually extract all the files:

 $size = getimagesize('zip:///path/to/file.zip#path/to/image.jpg'); 
+1
source share

All Articles