Solved

how to get image width, height from url

Posted on 2014-02-08
4
783 Views
Last Modified: 2014-04-01
My image url: http://i.viewimg.net/img/showbig/2014/02/09/52f6ef477efca.jpg

how to using php get image width height from url?
0
Comment
Question by:newbades
  • 2
4 Comments
 
LVL 2

Expert Comment

by:pierrejeanes
ID: 39844914
You probably have to use javascript or jquery
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39845025
'getimagesize' is made for that.  Info and examples here: http://us2.php.net/manual/en/function.getimagesize.php
0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 300 total points
ID: 39845212
Please see http://www.laprbass.com/RAY_temp_newbades.php

Outputs:
Array
(
    [0] => 5820
    [1] => 4832
    [2] => 2
    [3] => width="5820" height="4832"
    [bits] => 8
    [channels] => 3
    [mime] => image/jpeg
)

IMAGE AT http://i.viewimg.net/img/showbig/2014/02/09/52f6ef477efca.jpg IS 5,820 X 4,832 PIXELS

<?php // RAY_temp_newbades.php
error_reporting(E_ALL);

// SEE http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_28360134.html

// LOCATION OF THE IMAGE
$url = 'http://i.viewimg.net/img/showbig/2014/02/09/52f6ef477efca.jpg';

// WHAT WE CAN LEARN
$dat = getimagesize($url);

// SHOW THE USE OF THE DATA
echo '<pre>';
print_r($dat);
echo PHP_EOL;

$w = number_format($dat[0]);
$h = number_format($dat[1]);
echo "IMAGE AT $url IS $w X $h PIXELS";

Open in new window

0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 39846460
@newbades: I see you are relatively new to Experts Exchange.  When you give a marked-down grade (anything other than an "A") you are required to explain why the answer was deficient.  Please see the grading guidelines here:
http://support.experts-exchange.com/customer/portal/articles/481419

Since you got a tested and working code sample, and did not engage in any follow-on dialog for clarification, please explain why you did not award the default grade of "A" -- what were you expecting instead?

Standing by, ~Ray
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

895 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now