d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Getimagesize() Not Working
12Next
Add Reply New Topic New Poll
Member
Posts: 29,399
Joined: Dec 8 2007
Gold: 4,071.02
Aug 5 2012 10:08pm
so i got this image, its obviously a .jpg but for some reason getimagesize() isnt working for it
it returned nothing I tried to get the dimensions
and then i tried uploading it on tinypic and it wouldnt let me upload cuz it didnt recognize the file as a .jpg
anyone have a clue to wats goin on here??

the image uploaded successfully on imageshack:
http://imageshack.us/photo/my-images/827/error.JPG/

the [img] tags are not working here ;x

nvm guess the image upload failed on imageshack too

This post was edited by KyoDivine on Aug 5 2012 10:12pm
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Aug 5 2012 10:30pm
sounds like it's a different kind of file and just ends with .jpg. that would be your problem.
Member
Posts: 29,399
Joined: Dec 8 2007
Gold: 4,071.02
Aug 5 2012 10:57pm
Quote (carteblanche @ Aug 5 2012 09:30pm)
sounds like it's a different kind of file and just ends with .jpg. that would be your problem.


ya thats wut i figured, but is there any way to get the dimensions out of the pic?
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Aug 5 2012 11:36pm
try opening it in photoshop, gimp, paintshoppro, etc. im not a picture guy so i dont know how you'd do that. maybe someone in the graphics forum will know.
Member
Posts: 29,399
Joined: Dec 8 2007
Gold: 4,071.02
Aug 6 2012 03:03am
Quote (carteblanche @ Aug 5 2012 10:36pm)
try opening it in photoshop, gimp, paintshoppro, etc. im not a picture guy so i dont know how you'd do that. maybe someone in the graphics forum will know.


i just want a php code alternative to the getimagesize()
i know the dimensions alrdy, i just want a working code to be able to handle files like these ;o
was hoping someone on here knows
Member
Posts: 2,736
Joined: Nov 28 2009
Gold: 34.00
Aug 6 2012 02:05pm
Quote (KyoDivine @ 6 Aug 2012 11:03)
i just want a php code alternative to the getimagesize()
i know the dimensions alrdy, i just want a working code to be able to handle files like these ;o
was hoping someone on here knows


Can you upload the image on a filehost instead of a imagehost? That way, we can figure out what the problem is, because it's obviously something wrong with the file and not the function.
Member
Posts: 29,399
Joined: Dec 8 2007
Gold: 4,071.02
Aug 6 2012 06:29pm
Quote (eagl3s1ght @ Aug 6 2012 01:05pm)
Can you upload the image on a filehost instead of a imagehost? That way, we can figure out what the problem is, because it's obviously something wrong with the file and not the function.


http://www.2shared.com/photo/ONsOTS5k/error.html here it is
apparently its some sort of malformed jpg and i need to adjust my code to be able to handle these kind of files
anyone knows wat to do here??

edit:
so on the php site
it said
"Note:
Some formats may contain no image or may contain multiple images. In these cases, getimagesize() might not be able to properly determine the image size. getimagesize() will return zero for width and height in these cases."
souce: http://us3.php.net/manual/en/function.getimagesize.php

im guessing this is whats happening here, but it doesnt really offer a solution? is there some other sort of code i should be using here?

This post was edited by KyoDivine on Aug 6 2012 06:50pm
Member
Posts: 2,736
Joined: Nov 28 2009
Gold: 34.00
Aug 7 2012 02:23am
Quote (KyoDivine @ 7 Aug 2012 02:29)
http://www.2shared.com/photo/ONsOTS5k/error.html here it is
apparently its some sort of malformed jpg and i need to adjust my code to be able to handle these kind of files
anyone knows wat to do here??

edit:
so on the php site
it said
"Note:
Some formats may contain no image or may contain multiple images. In these cases, getimagesize() might not be able to properly determine the image size. getimagesize() will return zero for width and height in these cases."
souce: http://us3.php.net/manual/en/function.getimagesize.php

im guessing this is whats happening here, but it doesnt really offer a solution? is there some other sort of code i should be using here?


getimagesize() works fine for me.
http://codepad.viper-7.com/B4MiZs

Code
<?php

$size = getimagesize('http://localhostr.com/files/8oEwcrO/error.jpg');
print_r($size);

?>

Code
Array ( [0] => 200 [1] => 130 [2] => 2 [3] => width="200" height="130" [bits] => 8 [channels] => 3 [mime] => image/jpeg )


You probably couldn't have chosen a more sketchy host bro. How about localhostr.com next time?


This post was edited by eagl3s1ght on Aug 7 2012 02:23am
Member
Posts: 29,399
Joined: Dec 8 2007
Gold: 4,071.02
Aug 7 2012 07:04am
Quote (eagl3s1ght @ Aug 7 2012 01:23am)
getimagesize() works fine for me.
http://codepad.viper-7.com/B4MiZs

Code
<?php

$size = getimagesize('http://localhostr.com/files/8oEwcrO/error.jpg');
print_r($size);

?>

Code
Array ( [0] => 200 [1] => 130 [2] => 2 [3] => width="200" height="130" [bits] => 8 [channels] => 3 [mime] => image/jpeg )


You probably couldn't have chosen a more sketchy host bro. How about localhostr.com next time?
http://1.imgland.net/Sqg3GzV.png


lol sry i dont know file hostin sites.. i just did a quick google search and that one came up ;o
hmmmm very weird... its not workign for me on my code..
this is the code i have:

<?php
if (($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Error: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Stored in: " . $_FILES["file"]["tmp_name"] . "<br .>";

list($width, $height, $type, $attr) = getimagesize($_FILES["file"]["tmp_name"]);

echo "Image width " .$width;
echo "<BR>";
echo "Image height " .$height;
echo "<BR>";
echo "Attribute " .$attr;
}
}
else
{
echo "Invalid file";
}
?>

i uploaded my code on some free hosting i found, here is the address:
http://jpgcw.site11.com/
i test'd it with other .jpg and it works fine, but that error one doesnt work
i tried entering in ur url for the pic and it worked, maybe something weird is going on with the uploading script?
but it shows that the upload is successful

This post was edited by KyoDivine on Aug 7 2012 07:05am
Member
Posts: 2,736
Joined: Nov 28 2009
Gold: 34.00
Aug 9 2012 11:14am
Quote (KyoDivine @ 7 Aug 2012 15:04)
lol sry i dont know file hostin sites.. i just did a quick google search and that one came up ;o
hmmmm very weird... its not workign for me on my code..
this is the code i have:

<?php
if (($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Error: " . $_FILES["file"]["error"] . "<br />";
    }
  else
    {
    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
    echo "Type: " . $_FILES["file"]["type"] . "<br />";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
    echo "Stored in: " . $_FILES["file"]["tmp_name"] . "<br .>";

list($width, $height, $type, $attr) = getimagesize($_FILES["file"]["tmp_name"]);

echo "Image width " .$width;
echo "<BR>";
echo "Image height " .$height;
echo "<BR>";
echo "Attribute " .$attr;
    }
  }
else
  {
  echo "Invalid file";
  }
?>

i uploaded my code on some free hosting i found, here is the address:
http://jpgcw.site11.com/
i test'd it with other .jpg and it works fine, but that error one doesnt work
i tried entering in ur url for the pic and it worked, maybe something weird is going on with the uploading script?
but it shows that the upload is successful


If you want me to test this, you need to include the HTML form inputs.
Don't forget to use [CODE] tags.
Go Back To Programming & Development Topic List
12Next
Add Reply New Topic New Poll