Solved

how to get image width, height from url

Posted on 2014-02-08
4
791 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 109

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 109

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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…
The viewer will learn how to count occurrences of each item in an array.

786 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