Online, etc. I am working overtime on Saturday and week to solve this problem. how can I get the length and width of the uploaded image?

Source: Internet
Author: User
Online, etc. I am working overtime on Saturday and week to solve this problem. how can I get the length and width of the uploaded image?
List ($ width, $ height, $ type, $ attr) = getimagesize ('http: // 192.168.254.20/Public/images/0.jpg ');
Echo $ width;
Echo $ height;
Echo $ attr;


$ Img = imagecreatefromjpeg ("http: // 192.168.254.20/Public/images/0.jpg ");
Echo imagesx ($ img );
Echo "imagesy ($ img )";
Exit;
Neither method works and no data is output. The image path is correct. you can open the image.


Reply to discussion (solution)

The first method is acceptable, and you are suspected of having problems with your path.
List ($ width, $ height, $ type, $ attr) = getimagesize ('http: // avatar.csdn.net/1/9/2/1_mengfk000.jpg ');
Print_r ($ width); echo"
";
Print_r ($ height); echo"
";
Print_r ($ attr); echo"
";

Enable the php error prompt function.

If the image can be opened, at least the second type has output. The first is because getimagesize ('Http ://192.168.254.20/Public/images/0.jpg '); there is a space in front of the path.

print_r(getimagesize('http://avatar.csdn.net/1/9/2/1_mengfk000.jpg'));
Array
(
[0] = & gt; 150
[1] => 150.
[2] => 2
[3] => width = "150" height = "150"
[Bits] => 8
[Channels] => 3
[Mime] => image/jpeg
)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.