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

C

Csaba Gabor

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.geocities.com/img/filemgr/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
 
C

Csaba Gabor

Csaba said:
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\xC0" .
"\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
 
V

VK

Csaba said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top