Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 831
  • Last Modified:

how to get image width, height from url

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
newbades
Asked:
newbades
  • 2
1 Solution
 
pierrejeanesCommented:
You probably have to use javascript or jquery
0
 
Dave BaldwinFixer of ProblemsCommented:
'getimagesize' is made for that.  Info and examples here: http://us2.php.net/manual/en/function.getimagesize.php
0
 
Ray PaseurCommented:
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
 
Ray PaseurCommented:
@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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now