473,399 Members | 3,106 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Image return /print

me
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
Jul 17 '05 #1
7 15126
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
Jul 17 '05 #2
me

"Erwin Moller"
<si******************************************@spam yourself.com> wrote in
message news:3f***********************@news.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");?
Jul 17 '05 #3
me wrote:

"Erwin Moller"
<si******************************************@spam yourself.com> wrote in
message news:3f***********************@news.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.

Jul 17 '05 #4

On 29-Sep-2003, "me" <so*****@microsoft.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
www.creative-light.com
Jul 17 '05 #5

"me" <so*****@microsoft.com> wrote in message
news:Yv***********************@pollux.casema.net.. .

"Erwin Moller"
<si******************************************@spam yourself.com> wrote in
message news:3f***********************@news.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" :)
Jul 17 '05 #6
On Mon, 29 Sep 2003 15:54:32 GMT, "Tom Thackrey"
<to***@creative-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

Jul 17 '05 #7
Jason wrote:

"me" <so*****@microsoft.com> wrote in message
news:Yv***********************@pollux.casema.net.. .

"Erwin Moller"
<si******************************************@spam yourself.com> wrote in
message news:3f***********************@news.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. ;-)

Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Henri Schomäcker | last post by:
Hi folks, I got a windows com executable which returns a jpg image in a BSTR. Let's say, the var that holds the data is $imgData. With perl, in a cgi script, I may simpy write:...
9
by: Steffen Brodowski | last post by:
Hello everyone, since one week, I'm programming with python. Its a realy interesting tool. I wrote a script for generating barcodes in jpg-format. Everything is ok, but my function...
9
by: matthiasjanes | last post by:
Hi, Maybe someone of you can help me. I'm trying to display an image in memory(open file) with an cgi script - but it want work proberly: I'm running an Cgi webserver (CgiServerGui.py). ...
17
by: PyPK | last post by:
Hi I am looking for a simple tiff Image reader/writer in python.Can anyone point me to the right one.
5
by: Tompa | last post by:
Hi, I would like to create images on the fly as a response to an http request. I can do this with PIL like this (file create_gif.py): from PIL import Image, ImageDraw print 'Status: 200 OK'...
1
by: Jason | last post by:
For some reason, most but not all reports printing from an access application our client is using will not print any images on the reports or forms. One report will print the image and data...
0
by: Sergei Shelukhin | last post by:
I need to generate an image to print on a small card (15cm x 5cm), the image will be cut from the standart a4 sheet; it was done by MS Access proggie before and I'm rewriting it into ASP.NET. I...
1
by: sravani1 | last post by:
This code runs like when i submit the form it takes the image and displayed and top of the image a map will displayed. But actually i want that when i give the image it checks the location in the map...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.