Solved

how to get image width, height from url

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

820 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