Professional Web Applications Themes

Image return /print - PHP Development

Hey all, well i am also a newbie :) i saw this on many sites: <img src="somephp.php?blabla" width="100"> how can i make that to? i want to reffer to a php file that returns or prints a jpg image and in the <img src=must be a php url> Best regards M...

  1. #1

    Default Image return /print

    Hey all,
    well i am also a newbie :)

    i saw this on many sites:
    <img src="somephp.php?blabla" width="100">

    how can i make that to?

    i want to reffer to a php file that returns or prints a jpg image and in the
    <img src=must be a php url>

    Best regards M


    me Guest

  2. #2

    Default Re: Image return /print

    me wrote:
    > Hey all,
    > well i am also a newbie :)
    >
    > i saw this on many sites:
    > <img src="somephp.php?blabla" width="100">
    >
    > how can i make that to?
    >
    > i want to reffer to a php file that returns or prints a jpg image and in
    > the <img src=must be a php url>
    >
    > Best regards M
    Hi,

    You should somephp.php?blabla return an image, including the right headers
    for MIME-TYPE and such.
    Should work as you described above.

    The trouble will be generating a script that does that. You will have to do
    some more research on imagelibs in PHP.

    Good luck,
    Erwin Moller
    Erwin Moller Guest

  3. #3

    Default Re: Image return /print


    "Erwin Moller"
    <since_humans_read_this_I_am_spammed_too_muchspam yourself.com> wrote in
    message news:3f780f80$0$58709$e4fe514cnews.xs4all.nl...
    > me wrote:
    >
    > > Hey all,
    > > well i am also a newbie :)
    > >
    > > i saw this on many sites:
    > > <img src="somephp.php?blabla" width="100">
    > >
    > > how can i make that to?
    > >
    > > i want to reffer to a php file that returns or prints a jpg image and in
    > > the <img src=must be a php url>
    > >
    > > Best regards M
    >
    > Hi,
    >
    > You should somephp.php?blabla return an image, including the right headers
    > for MIME-TYPE and such.
    > Should work as you described above.
    >
    > The trouble will be generating a script that does that. You will have to
    do
    > some more research on imagelibs in PHP.
    >
    > Good luck,
    > Erwin Moller
    Thanks,

    i did some testing with this code:

    header("Contet-type: image/jpeg");
    $theURL="image.jpg";
    if(!($fp=fopen($theURL,"rb")))
    {
    print("Could not open the URL.");
    exit;
    }
    $contents=fread($fp,1000000);


    print($contents);
    fclose($fp);


    But must i always set the header("Contet-type: image/jpeg") before the code
    begins or can i make first a musql query orso to get the rigth image and
    then print the header("Contet-type: image/jpeg");?


    me Guest

  4. #4

    Default Re: Image return /print

    me wrote:
    >
    > "Erwin Moller"
    > <since_humans_read_this_I_am_spammed_too_muchspam yourself.com> wrote in
    > message news:3f780f80$0$58709$e4fe514cnews.xs4all.nl...
    >> me wrote:
    >>
    >> > Hey all,
    >> > well i am also a newbie :)
    >> >
    >> > i saw this on many sites:
    >> > <img src="somephp.php?blabla" width="100">
    >> >
    >> > how can i make that to?
    >> >
    >> > i want to reffer to a php file that returns or prints a jpg image and
    >> > in the <img src=must be a php url>
    >> >
    >> > Best regards M
    >>
    >> Hi,
    >>
    >> You should somephp.php?blabla return an image, including the right
    >> headers for MIME-TYPE and such.
    >> Should work as you described above.
    >>
    >> The trouble will be generating a script that does that. You will have to
    > do
    >> some more research on imagelibs in PHP.
    >>
    >> Good luck,
    >> Erwin Moller
    >
    > Thanks,
    >
    > i did some testing with this code:
    >
    > header("Contet-type: image/jpeg");
    that is content-type, no contet-type.
    > $theURL="image.jpg";
    > if(!($fp=fopen($theURL,"rb")))
    > {
    > print("Could not open the URL.");
    this is a bit odd. You have set the header to image, but your output is
    plain text..
    Not good.

    Your html-page is asking for an image, and your script should return one.
    In your case, where it cannot find the right image, try to send back an
    image you know that exists containing "NOT AVAILABLE" written on it or
    somethinf like that.
    Do not send plain text to the browser when it expects an image.
    Better write an error to some logfile.
    > exit;
    > }
    > $contents=fread($fp,1000000);
    >
    >
    > print($contents);
    > fclose($fp);
    >
    >
    > But must i always set the header("Contet-type: image/jpeg") before the
    > code begins or can i make first a musql query orso to get the rigth image
    > and then print the header("Contet-type: image/jpeg");?
    You can do whatever you like AS LONG AS YOU DO NOT GENERATE OUTPUT.
    :-)
    The headers should come first.

    Erwin Moller Guest

  5. #5

    Default Re: Image return /print


    On 29-Sep-2003, "me" <someonemicrosoft.com> wrote:
    > i saw this on many sites:
    > <img src="somephp.php?blabla" width="100">
    >
    > how can i make that to?
    <img src="getimage.php?fn=image1" ...>

    getimage.php:
    <?php

    if (isset($_GET['fn']))
    $image = $_GET['fn'];
    else
    $image = 'error';

    header("Content-Type: image/jpeg\n");
    header("Content-Transfer-Encoding: binary");

    $fp=fopen("images/$image.jpg" , "r");
    if ($fp)
    fpassthru($fp);

    ?>


    --
    Tom Thackrey
    [url]www.creative-light.com[/url]
    Tom Thackrey Guest

  6. #6

    Default Re: Image return /print


    "me" <someonemicrosoft.com> wrote in message
    news:YvUdb.391862$0W5.11564308pollux.casema.net.. .
    >
    > "Erwin Moller"
    > <since_humans_read_this_I_am_spammed_too_muchspam yourself.com> wrote in
    > message news:3f780f80$0$58709$e4fe514cnews.xs4all.nl...
    > > me wrote:
    > >
    > > > Hey all,
    > > > well i am also a newbie :)
    > > >
    > > > i saw this on many sites:
    > > > <img src="somephp.php?blabla" width="100">
    > > >
    > > > how can i make that to?
    > > >
    > > > i want to reffer to a php file that returns or prints a jpg image and
    in
    > > > the <img src=must be a php url>
    > > >
    > > > Best regards M
    > >
    > > Hi,
    > >
    > > You should somephp.php?blabla return an image, including the right
    headers
    > > for MIME-TYPE and such.
    > > Should work as you described above.
    > >
    > > The trouble will be generating a script that does that. You will have to
    > do
    > > some more research on imagelibs in PHP.
    > >
    > > Good luck,
    > > Erwin Moller
    >
    > Thanks,
    >
    > i did some testing with this code:
    >
    > header("Contet-type: image/jpeg");
    > $theURL="image.jpg";
    > if(!($fp=fopen($theURL,"rb")))
    > {
    > print("Could not open the URL.");
    > exit;
    > }
    > $contents=fread($fp,1000000);
    >
    >
    > print($contents);
    > fclose($fp);
    >
    >
    > But must i always set the header("Contet-type: image/jpeg") before the
    code
    > begins or can i make first a musql query orso to get the rigth image and
    > then print the header("Contet-type: image/jpeg");?
    >
    >
    >
    Maybe try "Content-type" and not "Contet-type" :)


    Jason Guest

  7. #7

    Default Re: Image return /print

    On Mon, 29 Sep 2003 15:54:32 GMT, "Tom Thackrey"
    <tomnrcreative-light.com> wrote:
    ><img src="getimage.php?fn=image1" ...>
    >
    >getimage.php:
    ><?php
    >
    >if (isset($_GET['fn']))
    > $image = $_GET['fn'];
    >else
    > $image = 'error';
    >
    >header("Content-Type: image/jpeg\n");
    >header("Content-Transfer-Encoding: binary");
    >
    >$fp=fopen("images/$image.jpg" , "r");
    >if ($fp)
    > fpassthru($fp);
    >
    >?>
    another way to do it:

    getimage.php:
    <?php
    if (isset($_GET['fn']))
    {
    $image = $_GET['fn'];
    header("Location: images/$image.jpg");
    }
    else
    {
    header("HTTP/1.0 404 Not Found");
    }
    ?>

    - allan savolainen

    Allan Savolainen Guest

  8. #8

    Default Re: Image return /print

    Jason wrote:
    >
    > "me" <someonemicrosoft.com> wrote in message
    > news:YvUdb.391862$0W5.11564308pollux.casema.net.. .
    >>
    >> "Erwin Moller"
    >> <since_humans_read_this_I_am_spammed_too_muchspam yourself.com> wrote in
    >> message news:3f780f80$0$58709$e4fe514cnews.xs4all.nl...
    >> > me wrote:
    >> >
    >> > > Hey all,
    >> > > well i am also a newbie :)
    >> > >
    >> > > i saw this on many sites:
    >> > > <img src="somephp.php?blabla" width="100">
    >> > >
    >> > > how can i make that to?
    >> > >
    >> > > i want to reffer to a php file that returns or prints a jpg image and
    > in
    >> > > the <img src=must be a php url>
    >> > >
    >> > > Best regards M
    >> >
    >> > Hi,
    >> >
    >> > You should somephp.php?blabla return an image, including the right
    > headers
    >> > for MIME-TYPE and such.
    >> > Should work as you described above.
    >> >
    >> > The trouble will be generating a script that does that. You will have
    >> > to
    >> do
    >> > some more research on imagelibs in PHP.
    >> >
    >> > Good luck,
    >> > Erwin Moller
    >>
    >> Thanks,
    >>
    >> i did some testing with this code:
    >>
    >> header("Contet-type: image/jpeg");
    >> $theURL="image.jpg";
    >> if(!($fp=fopen($theURL,"rb")))
    >> {
    >> print("Could not open the URL.");
    >> exit;
    >> }
    >> $contents=fread($fp,1000000);
    >>
    >>
    >> print($contents);
    >> fclose($fp);
    >>
    >>
    >> But must i always set the header("Contet-type: image/jpeg") before the
    > code
    >> begins or can i make first a musql query orso to get the rigth image and
    >> then print the header("Contet-type: image/jpeg");?
    >>
    >>
    >>
    >
    > Maybe try "Content-type" and not "Contet-type" :)
    Hi Jason,

    That might help maybe. ;-)

    Erwin Moller Guest

Similar Threads

  1. How can I return a binary file (image) from a web service
    By klj_mcsd@hotmail.com in forum ASP.NET Web Services
    Replies: 1
    Last Post: June 25th, 11:20 PM
  2. Replies: 4
    Last Post: April 25th, 08:26 PM
  3. Cannot Print Image
    By kEN_ZIELINSKI@adobeforums.com in forum Adobe Illustrator Windows
    Replies: 2
    Last Post: April 15th, 02:42 PM
  4. How to return image URL via web service
    By Chris Wollesen in forum ASP.NET Web Services
    Replies: 2
    Last Post: November 30th, 08:19 AM
  5. Image print quality
    By pi0neer in forum Photography
    Replies: 8
    Last Post: July 19th, 08:58 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139