469,609 Members | 1,198 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,609 developers. It's quick & easy.

Image Q: built into browser/serving from read only directory

Not sure of best place for this question...
Are there any built in images within the browser that I can assume
(particularly IE and FF)?

More specifically, I am writing a one file webApp.php application which
needs one tiny little folder icon (e.g.
http://us.geo1.yimg.com/pic.geocitie...gr/folder.gif). Now
I could have a second file of the folder icon, but I would rather only
have one text file to distribute (namely, webApp.php). Of course, it
would be improper to reference a foreign website to get ahold of an
image each time. Therefore, if the browsers have some built in
standard images that I could access, it would be extremely helpful.

Somehow, I doubt it exists but I was bound to ask. So, here is an
alternate plan, failing that. I install the single webApp.php file.
When it is run, it checks for the existence of folder.gif in its own
directory and if it's not there, it creates the file itself (using data
embedded within webApp.php). The problem is that this doesn't cover
write protected directories (and I really want to avoid hitting a
remote server).

Now in Firefox it is possible to specify the actual bytes of an image.
In other words, I don't need to have
src="http://webAppDomain.com/image.jpg" but can do src="data:..."
(sorry if I've messed up on the details here). However, I don't think
IE supports this yet. That is why I've been casting about for an
alternate approach.

Ultimately, I can solve this problem by pointing the image's src to
"http://webAppDomain.com/webApp.php?getImage=folder" and have
webApp.php spit out the image in this case, but a simpler, more
straightforward solution would be preferred.

Thanks for any tips,
Csaba Gabor from Vienna

Nov 23 '05 #1
3 1356
Csaba Gabor wrote:
Ultimately, I can solve this problem by pointing the image's src to
"http://webAppDomain.com/webApp.php?getImage=folder" and have
webApp.php spit out the image in this case, but a simpler, more
straightforward solution would be preferred.


This question was a technology question, and not specific to any
particular one. Therefore, even though I don't have a client side
solution I'm happy with, in the absence of other replies, and in the
interest of at least one solution, I detail what works for me, though
it is PHP and not javascript. At the top of the webApp.php file I
have:

<?php
if ($_REQUEST && $imgName = $_REQUEST['sendImage'])
sendImage($imgName);

function sendImage($imgName) {
header("Content-type: image/gif");
$gif = "GIF89a\x0F\x00\x0D\x00\xA2\xFF\x00\xC0\xC0\xC 0" .
"\xFF\xFF\x00\xC0\xC0\xC0\x80\x80" .
"\x80\x00\x00\x00\x00\x00\x00\x00" .
"\x00\x00\x00\x00\x00\x21\xF9\x04" .
"\x01\x00\x00\x00\x00\x2C\x00\x00" .
"\x00\x00\x0F\x00\x0D\x00\x40\x03" .
"\x33\x08\x30\xCC\xFA\x6F\x80\x20" .
"\xA8\xAD\x75\x10\x79\x7B\x26\x00" .
"\x21\x8E\x24\x39\x60\x57\xD3\x2C" .
"\x13\xEA\x06\x1A\xF7\xA2\xDA\xE2" .
"\x4A\x90\x82\xE7\x79\x0C\xCC\xA9" .
"\xCD\xCF\x13\x94\x00\x31\x31\x95" .
"\x52\x45\x48\x00\x00\x3B";
$size = strlen($gif);
header("Content-Length: $size bytes");
print ($gif);
exit();
}
?>

One would call this like
<img src='http://webAppDomain/webApp.php?sendImage=folder'> Now it
might be that because the src is always the same, the image will be
cached and the server won't be hit again for subsequent requests. But
I forget whether or not that .php will cause the browser to ignore the
cache. If so, then what could be done is to replace that
webApp.php?sendImage=folder with folder.gif and have your Apache web
browser rewrite the folder.gif request to webApp.php?sendImage=folder.
Of course that steps outside the bounds of the original problem since
apache's httpd.conf file would be getting modified. Some further
comments on this approach to cacheing may be found at
http://php.net/imagecreatefrompng

Csaba Gabor from Vienna

Nov 23 '05 #2
VK

Csaba Gabor wrote:
Are there any built in images within the browser that I can assume
(particularly IE and FF)?
Yes and now - and in any case cannot be used :-)

Yes, any GUI browser uses some build-in images for its system screens
(and not only for that :-)

For example Firexox has a foxy globe:
chrome://browser/content/about.png

And IE has a bunch of little signs like
res://C:\WINDOWS\SYSTEM\SHDOCLC.DLL/pagerror.gif

Netscape 4.0x will show you the original Mozilla Little Dragon - but
with French baguette in his hand - if you type about:francais

And Him only knows what else is inside of things which are not made by
ourselves, but by rather young and often joyful people. By the way, did
you read yet The Book Of Mozilla? If not then this attractive reading
is waiting for you if you type about:mozilla in Firefox.

The "no" part of my answer is: these are all local system resources so
you cannot reach them if you page has been downloaded from a server.
Also the set and exact name/location of these pictures varies greatly
from one release to another.

Now in Firefox it is possible to specify the actual bytes of an image.
In other words, I don't need to have
src="http://webAppDomain.com/image.jpg" but can do src="data:..."
(sorry if I've messed up on the details here). However, I don't think
IE supports this yet.


"yet" is a wrong word here - we should say "still". Yes, any GUI
browser starting from NCSA Mosaic and including Internet Explorer
supports X Bitmap format - and pictures in this format can be generated
by JavaScript and inserted into <img>

So X Bitmap is totally universal solution (as long as JavaScript itself
is enabled) but this format supports only black'n'white pictures.

You may also consider VML and SVG vector graphics. VML is supported by
default by IE - but only by IE. SVG will be natively supported by
Firefox 1.5 but will require plugin right now.

Nov 23 '05 #3
On 2005-11-21, VK <sc**********@yahoo.com> wrote:
Now in Firefox it is possible to specify the actual bytes of an image.
In other words, I don't need to have
src="http://webAppDomain.com/image.jpg" but can do src="data:..."
(sorry if I've messed up on the details here). However, I don't think
IE supports this yet.


"yet" is a wrong word here - we should say "still". Yes, any GUI
browser starting from NCSA Mosaic and including Internet Explorer
supports X Bitmap format - and pictures in this format can be generated
by JavaScript and inserted into <img>

So X Bitmap is totally universal solution (as long as JavaScript itself
is enabled) but this format supports only black'n'white pictures.


Is there support for X Pixmap ? -
hmm xpm seems to be a rather complex format

it'd try it here but I'm running X so I'd not be sure it it was X or mozilla
rendering it.

MS-windows icon format is also supported on linux (for site icons) but
mozilla also supports other bitmaps up there (png, jpg, - even animated gifs)

Bye.
Jasen
Nov 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by GAR | last post: by
23 posts views Thread by Erik Schulp | last post: by
6 posts views Thread by juglesh | last post: by
reply views Thread by Satish Appasani | last post: by
17 posts views Thread by santel_helvis | last post: by
1 post views Thread by KoRnDragon | last post: by
8 posts views Thread by Alexander Fischer | last post: by
7 posts views Thread by =?Utf-8?B?TWlrZQ==?= | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.