read .jpg files

User avatar
John
Site Admin
Posts: 2622
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH
Contact:

read .jpg files

Post by John »

To directly put the filename in, the file would need to be in the web-tree, which is why you need to use the spew. The function that sends the image should be fairly simple, e.g.

<EXPORT $vthumbnailfile URL>

<A NAME=showimage PUBLIC>
<spew $vthumbnailfile>
</A>

...
<IMG SRC="$url/showimage.jpg">
...

It's important to have the .jpg extension on the IMG SRC, and also that you don't accidentally produce other output in the showimage function.
John Turnbull
Thunderstone Software
iclbloom
Posts: 103
Joined: Mon May 07, 2001 5:51 pm

read .jpg files

Post by iclbloom »

This is was my solution for the problem, thanks for your help.

<strfmt "%s%s%s%s%s%s%s%s%s%s%s%s%s" '<a href\="' $fakeurl '/showbigimage\.html\?imagefn\=' $vfullimagefn '&htmfn\=' $vfilename '"><img src="' $fakeurl '/fshowsrc.jpg\?disp=' $newthumb '" alt="' $vcaption '"></a>' >


now I am trying to use BLOB field type for a bunch of small .gif files

import schema
...
field i_filename varchar(10) 1
field I_image blob 2
...

sql insert stmt:
...
$i_filename,
fromfile($i_filename)
...
my question is, How do I retrieve and display the gif image in the blob field?
Can't use send, can't use spew, just plain $i_image does not seem to work, below
is an attempt to pass the filename and showsrc does a query and displays (using $i_image),
This does not work

<img src="$url/fshowsrc.gif?disp=$i_filename">


Thanks
Leon Bloom
bart
Posts: 251
Joined: Wed Apr 26, 2000 12:42 am

read .jpg files

Post by bart »

User avatar
John
Site Admin
Posts: 2622
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH
Contact:

read .jpg files

Post by John »

The push demo above uses <spew> with an indirect for the large image, and <fmt %s> with a varbyte for the thumbnail. You should convert the blob to a varbyte in the select, and use <fmt %s> to display it, e.g.

<a name=fshowsrc public>
<sql MAX=1 "select convert(l_image, 'varbyte') Img from Table where ...">
<fmt %s $Img>
</sql>
</a>

Obviously it is important that you don't generate any other output in the function that would cause the data to no longer be a valid image.
John Turnbull
Thunderstone Software
iclbloom
Posts: 103
Joined: Mon May 07, 2001 5:51 pm

read .jpg files

Post by iclbloom »

This is what I have so far, not working yet, is my <header... tag correct?

Thanks
Leon Bloom


<img src="$url/fjohn.gif?disp=$i_filename">

...

<a name=fjohn public>
<header name="Content-Type: image/gif">
<sql MAX=1 "select convert(i_image, 'varbyte') img
from
janes_images
where
i_filename = $disp">
<fmt %s $img>
</sql>
</a>
User avatar
John
Site Admin
Posts: 2622
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH
Contact:

read .jpg files

Post by John »

That looks mostly correct, although it should know gif automatically. The two things that I would suggest would be to URL encode the filename, not sure if there are any strange characters:

<strfmt %U $i_filename>
<img src="$url/fjohn.gif?disp=$ret">

And if that doesn't work, create a hyperlink instead:

<A HREF=="$url/fjohn2.txt?disp=$ret">

...

<a name=fjohn2 public>
<header name="Content-Type: image/gif">
<sql MAX=1 "select i_filename img
from
janes_images
where
i_filename = $disp">
<fmt %s $img>
</sql>
Found $loop rows
</a>

To make sure it is finding the row.
John Turnbull
Thunderstone Software
iclbloom
Posts: 103
Joined: Mon May 07, 2001 5:51 pm

read .jpg files

Post by iclbloom »

This was the winning combination, thanks.

<strfmt %U $i_filename><$url_i_filename = $ret>
<img src="$url/fjohn2.gif?disp=$url_i_filename">

<a name=fjohn2 public>
<header name="Content-Type: image/gif">
<sql MAX=1 "select
convert(i_image, 'varbyte') img
from
janes_images_blob
where
i_filename = $disp
">
<fmt %s $img>
</sql>
</a>
Post Reply