Solved

how to get image width, height from url

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

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
This article discusses four methods for overlaying images in a container on a web page
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

760 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

18 Experts available now in Live!

Get 1:1 Help Now