By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,829 Members | 1,798 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,829 IT Pros & Developers. It's quick & easy.

How to find Image Height and width using PHP saved as Excel?

aveeva
P: 28
I have a folder with 100's images, how to find Height and width programmatically and output saved in Excel sheet?
Apr 30 '19 #1
Share this Question
Share on Google+
3 Replies


gits
Expert Mod 5K+
P: 5,295
well - the idea is

1 .to loop over all files in that folder - probably checking if the element is a file (and not a folder or non valid image) - then check the mimetype or some other fileinfo - and identify if its a valid image you want to handle then

2. you can use getimagesize to retrieve the image dimensions then

3. store that for now in some result-structure (array or object - whatever you like to use) then

4. use something like PhpSpreadsheet to create your spreadsheet from the result-structure
Apr 30 '19 #2

Expert 100+
P: 1,035
A, slighty more simple, way would be to skip step 3 and 4. Echo the values to output and create a CSV-format like:
Expand|Select|Wrap|Line Numbers
  1. picture1.jpg,1280,1024
  2. picture2.jpg,1920,1080
  3. picture3.jpg,1080,1920
Excel is your friend here. you do not need to create an excel file, because Excel is capable of reading CSV-files very well.

But, if you want to be an expert in PHP, than you should not skip steps 3 and 4 😂😉
Apr 30 '19 #3

gits
Expert Mod 5K+
P: 5,295
that might be :) usually a developers work should be to question the requirements as well - thus i agree with the csv-file creation - which is most likely even a bit more universal.
Apr 30 '19 #4

Post your reply

Sign in to post your reply or Sign up for a free account.