[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


PHP5: how to find an accurate ratio to resize imgs for mobile devices?

Posted on 2014-07-17
Medium Priority
Last Modified: 2014-07-17
Hello Experts,

I am able to resize images using PHP. However, I am struggling to calculate an accurate size for mobile devices... is there an accurate ration to resize images for mobile devices?

Thanks for you help.
Question by:epifanio67
LVL 58

Assisted Solution

Gary earned 668 total points
ID: 40202533
There are a multitude of differing resolutions for mobile devices.
Trying to size an image to fit every one is a waste of time and effort.
Look at the media queries that Bootrap uses and just using a sizing algorithm for those sizes and just use a 100% width/height to let the image scale itself

But if this is only to save a few bytes even resizing the image is a bit of a waste of time.
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 664 total points
ID: 40202554
You may not need to resize the images with PHP.  Have a look at this example.  Try different browsers and screen sizes.  Use "view source" to see what is going on.
LVL 34

Accepted Solution

Slick812 earned 668 total points
ID: 40202874
mobil devices have TWO views, vertical and horizontal,  AND it may be difficult to have any way to get the screen resolution of the mobil anyway for the PHP, you can have a phone with a 3 1/4 inch screen with a res of 320 x 240,  to a newer iphone wid 960 x 1704 res (and larger phone res), and there's also 60 inch large "WEB-TV" which may be set as mobil. . . .
it is best to have correct HTML5 and CSS3 for viewpoint and media responses. if you have complex "zone areas" of stacked elements, you can use javascript to do precise image sizing.

Author Closing Comment

ID: 40202923
Thank you experts.... your comments are very helpful...

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses
Course of the Month19 days, 22 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question