image dimensions ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Yang Li Ke

    image dimensions ?

    Hi guys!

    If someone post a link to an image like this:


    Is there any ways to find the images width and height?

    Thank you!
    --
    Yang


  • jn

    #2
    Re: image dimensions ?

    I didn't write the function below. It's from the comments section of
    getimagesize() on php.net:

    function getimagesize_re mote($image_url ) {
    $handle = fopen ($image_url, "rb");
    $contents = "";
    if ($handle) {
    do {
    $count += 1;
    $data = fread($handle, 8192);
    if (strlen($data) == 0) {
    break;
    }
    $contents .= $data;
    } while(true);
    } else { return false; }
    fclose ($handle);

    $im = ImageCreateFrom String($content s);
    if (!$im) { return false; }
    $gis[0] = ImageSX($im);
    $gis[1] = ImageSY($im);
    // array member 3 is used below to keep with current getimagesize standards
    $gis[3] = "width={$gi s[0]} height={$gis[1]}";
    ImageDestroy($i m);
    return $gis;
    }


    "Yang Li Ke" <yanglike@sympa tico.ca> wrote in message
    news:l6TSb.6891 9$Kg6.916289@ne ws20.bellglobal .com...[color=blue]
    > Hi guys!
    >
    > If someone post a link to an image like this:
    > http://ia.imdb.com/media/imdb/01/I/57/18/16m.jpg
    >
    > Is there any ways to find the images width and height?
    >
    > Thank you!
    > --
    > Yang
    >
    >
    >[/color]


    Comment

    • Yang Li Ke

      #3
      Re: image dimensions ?

      thank you!


      --


      "jn" <usenet*spamist ehsuckremovetor eply*@jasonnorr is.net> wrote in message
      news:LrUSb.1250 27$873.2605111@ twister.tampaba y.rr.com...[color=blue]
      > I didn't write the function below. It's from the comments section of
      > getimagesize() on php.net:
      >
      > function getimagesize_re mote($image_url ) {
      > $handle = fopen ($image_url, "rb");
      > $contents = "";
      > if ($handle) {
      > do {
      > $count += 1;
      > $data = fread($handle, 8192);
      > if (strlen($data) == 0) {
      > break;
      > }
      > $contents .= $data;
      > } while(true);
      > } else { return false; }
      > fclose ($handle);
      >
      > $im = ImageCreateFrom String($content s);
      > if (!$im) { return false; }
      > $gis[0] = ImageSX($im);
      > $gis[1] = ImageSY($im);
      > // array member 3 is used below to keep with current getimagesize[/color]
      standards[color=blue]
      > $gis[3] = "width={$gi s[0]} height={$gis[1]}";
      > ImageDestroy($i m);
      > return $gis;
      > }
      >
      >
      > "Yang Li Ke" <yanglike@sympa tico.ca> wrote in message
      > news:l6TSb.6891 9$Kg6.916289@ne ws20.bellglobal .com...[color=green]
      > > Hi guys!
      > >
      > > If someone post a link to an image like this:
      > > http://ia.imdb.com/media/imdb/01/I/57/18/16m.jpg
      > >
      > > Is there any ways to find the images width and height?
      > >
      > > Thank you!
      > > --
      > > Yang
      > >
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • CountScubula

        #4
        Re: image dimensions ?

        "Yang Li Ke" <yanglike@sympa tico.ca> wrote in message
        news:l6TSb.6891 9$Kg6.916289@ne ws20.bellglobal .com...[color=blue]
        > Hi guys!
        >
        > If someone post a link to an image like this:
        > http://ia.imdb.com/media/imdb/01/I/57/18/16m.jpg
        >
        > Is there any ways to find the images width and height?
        >
        > Thank you!
        > --
        > Yang
        >
        >[/color]

        $aryInfo = getimagesize("h ttp://ia.imdb.com/media/imdb/01/I/57/18/16m.jpg");

        --
        Mike Bradley
        http://www.gzentools.com -- free online php tools


        Comment

        • Chung Leong

          #5
          Re: image dimensions ?

          But getimagesize() works for URLs. So why use a custom function?

          Opening an user specified image file using the GD functions is rather
          dangerous. I could easily create a .GIF file that'd bring your server to its
          knees.

          Uzytkownik "jn" <usenet*spamist ehsuckremovetor eply*@jasonnorr is.net> napisal
          w wiadomosci news:LrUSb.1250 27$873.2605111@ twister.tampaba y.rr.com...[color=blue]
          > I didn't write the function below. It's from the comments section of
          > getimagesize() on php.net:
          >
          > function getimagesize_re mote($image_url ) {
          > $handle = fopen ($image_url, "rb");
          > $contents = "";
          > if ($handle) {
          > do {
          > $count += 1;
          > $data = fread($handle, 8192);
          > if (strlen($data) == 0) {
          > break;
          > }
          > $contents .= $data;
          > } while(true);
          > } else { return false; }
          > fclose ($handle);
          >
          > $im = ImageCreateFrom String($content s);
          > if (!$im) { return false; }
          > $gis[0] = ImageSX($im);
          > $gis[1] = ImageSY($im);
          > // array member 3 is used below to keep with current getimagesize[/color]
          standards[color=blue]
          > $gis[3] = "width={$gi s[0]} height={$gis[1]}";
          > ImageDestroy($i m);
          > return $gis;
          > }
          >
          >
          > "Yang Li Ke" <yanglike@sympa tico.ca> wrote in message
          > news:l6TSb.6891 9$Kg6.916289@ne ws20.bellglobal .com...[color=green]
          > > Hi guys!
          > >
          > > If someone post a link to an image like this:
          > > http://ia.imdb.com/media/imdb/01/I/57/18/16m.jpg
          > >
          > > Is there any ways to find the images width and height?
          > >
          > > Thank you!
          > > --
          > > Yang
          > >
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • Tim Tyler

            #6
            Re: image dimensions ?

            Chung Leong <chernyshevsky@ hotmail.com> wrote or quoted:
            [color=blue]
            > But getimagesize() works for URLs. So why use a custom function?[/color]

            According to the author:

            ``Using remote files with getimagesize($U RL) never worked for me.
            Except when I would grab files from the same server.''

            - http://uk.php.net/getimagesize
            --
            __________
            |im |yler http://timtyler.org/ tim@tt1lock.org Remove lock to reply.

            Comment

            • Chung Leong

              #7
              Re: image dimensions ?

              He must be using an ancient version of PHP. In any event it's stupid to load
              up the image just to get the dimensions.

              Uzytkownik "jn" <usenet*spamist ehsuckremovetor eply*@jasonnorr is.net> napisal
              w wiadomosci news:LrUSb.1250 27$873.2605111@ twister.tampaba y.rr.com...[color=blue]
              > I didn't write the function below. It's from the comments section of
              > getimagesize() on php.net:
              >
              > function getimagesize_re mote($image_url ) {
              > $handle = fopen ($image_url, "rb");
              > $contents = "";
              > if ($handle) {
              > do {
              > $count += 1;
              > $data = fread($handle, 8192);
              > if (strlen($data) == 0) {
              > break;
              > }
              > $contents .= $data;
              > } while(true);
              > } else { return false; }
              > fclose ($handle);
              >
              > $im = ImageCreateFrom String($content s);
              > if (!$im) { return false; }
              > $gis[0] = ImageSX($im);
              > $gis[1] = ImageSY($im);
              > // array member 3 is used below to keep with current getimagesize[/color]
              standards[color=blue]
              > $gis[3] = "width={$gi s[0]} height={$gis[1]}";
              > ImageDestroy($i m);
              > return $gis;
              > }
              >
              >
              > "Yang Li Ke" <yanglike@sympa tico.ca> wrote in message
              > news:l6TSb.6891 9$Kg6.916289@ne ws20.bellglobal .com...[color=green]
              > > Hi guys!
              > >
              > > If someone post a link to an image like this:
              > > http://ia.imdb.com/media/imdb/01/I/57/18/16m.jpg
              > >
              > > Is there any ways to find the images width and height?
              > >
              > > Thank you!
              > > --
              > > Yang
              > >
              > >
              > >[/color]
              >
              >[/color]


              Comment

              • Shawn Wilson

                #8
                Re: image dimensions ?

                Chung Leong wrote:[color=blue]
                >
                > He must be using an ancient version of PHP. In any event it's stupid to load
                > up the image just to get the dimensions.
                >
                > Uzytkownik "jn" <usenet*spamist ehsuckremovetor eply*@jasonnorr is.net> napisal
                > w wiadomosci news:LrUSb.1250 27$873.2605111@ twister.tampaba y.rr.com...[color=green]
                > > I didn't write the function below. It's from the comments section of
                > > getimagesize() on php.net:
                > >
                > > function getimagesize_re mote($image_url ) {
                > > $handle = fopen ($image_url, "rb");
                > > $contents = "";
                > > if ($handle) {
                > > do {
                > > $count += 1;
                > > $data = fread($handle, 8192);
                > > if (strlen($data) == 0) {
                > > break;
                > > }
                > > $contents .= $data;
                > > } while(true);
                > > } else { return false; }
                > > fclose ($handle);
                > >
                > > $im = ImageCreateFrom String($content s);
                > > if (!$im) { return false; }
                > > $gis[0] = ImageSX($im);
                > > $gis[1] = ImageSY($im);
                > > // array member 3 is used below to keep with current getimagesize[/color]
                > standards[color=green]
                > > $gis[3] = "width={$gi s[0]} height={$gis[1]}";
                > > ImageDestroy($i m);
                > > return $gis;
                > > }
                > >
                > >
                > > "Yang Li Ke" <yanglike@sympa tico.ca> wrote in message
                > > news:l6TSb.6891 9$Kg6.916289@ne ws20.bellglobal .com...[color=darkred]
                > > > Hi guys!
                > > >
                > > > If someone post a link to an image like this:
                > > > http://ia.imdb.com/media/imdb/01/I/57/18/16m.jpg
                > > >
                > > > Is there any ways to find the images width and height?
                > > >[/color][/color][/color]

                Also, a lot of sites have anti-hotlinking policies in place. So the image your
                server would get might be a "don't steal my bandwidth" image which would be
                different dimensions than the intended image. This would be most likely to
                happen if you sent a referrer that didn't match the website. I don't know how
                many sites do this if you don't send a referrer.

                Shawn
                --
                Shawn Wilson
                shawn@glassgian t.com

                Comment

                Working...