What can I do so that this image can be saved?

M

McKirahan

http://hesterloli.dnsalias.com/test/javascript_image.htm

The image is the 100x100 px block. If we right-click in it and try to save
the image we cannot. Is it possible to say set a mime-type so that it can
be saved? Thanks.

--
George Hester
__________________________________

What image? I got an empty square box!

Looking at your source I see that you're generating an image not displaying
one from a file.

<script>
//XBM image start
var tiny = '#define x_width 1\n';
tiny += '#define x_height 1\n';
tiny += 'static char x_bits[] = {';
tiny += '0x00'; //image data
tiny += '};';
</script>

<img src="javascript:tiny" name="Single pixel image" width="100"
height="100" border="2" />

Good luck with that; I'm not familiar with it.
 
G

George Hester

McKirahan said:
http://hesterloli.dnsalias.com/test/javascript_image.htm

The image is the 100x100 px block. If we right-click in it and try to save
the image we cannot. Is it possible to say set a mime-type so that it can
be saved? Thanks.

--
George Hester
__________________________________

What image? I got an empty square box!

Looking at your source I see that you're generating an image not displaying
one from a file.

<script>
//XBM image start
var tiny = '#define x_width 1\n';
tiny += '#define x_height 1\n';
tiny += 'static char x_bits[] = {';
tiny += '0x00'; //image data
tiny += '};';
</script>

<img src="javascript:tiny" name="Single pixel image" width="100"
height="100" border="2" />

Good luck with that; I'm not familiar with it.

Hi McKirahan:

It turns out this can actually be used to keep any image from being able to save from the web.
Sure a well versed Internet user probably can save the image but using this and z-index we could lay this
XBM image over say a jpg and the image would not be savable without extra work.

I haven't done it here but I did it elsewhere. Works pretty good.

I do know that the actual construction of the XBM can take a while. But it is only 1px so it shouldn't be
noicable.

George Hester
__________________________________
 
G

George Hester

Paul Cooper said:
Just look in the cache!

Just do many things. Except right-click Save picture... Unless of course someone knows how to set the Mime type for it. I think it is a bitmap. The official mime-type is image/x-bitmap. But then that doesn't explain the weird error when it is tried.

George Hester
__________________________________
 
L

Lee

George Hester said:
Just do many things. Except right-click Save picture... Unless of =
course someone knows how to set the Mime type for it. I think it is a =
bitmap. The official mime-type is image/x-bitmap. But then that =
doesn't explain the weird error when it is tried.

It's not a matter of mime-type. The "source" of the image is a
Javascript function. When you try to save it, the browser tries
to rerun the function, but out of scope, so it fails.
 
G

George Hester

Lee said:
George Hester said:


It's not a matter of mime-type. The "source" of the image is a
Javascript function. When you try to save it, the browser tries
to rerun the function, but out of scope, so it fails.

OK that's an explanation I understand. Can I write it to a file then? Permissions allowing assumed. Thanks.

George Hester
__________________________________
 
K

kaeli

Did you try it with firefox?

No, sorry, I really should have looked at the file first.
I thought it was the standard garbage we see all the time here.
My bad. I should have read the whole thread. Well, we know how much I like to
make an idiot of myself now and then. (Don't say it)

That's very odd. A hex image generated by script.
And of course useless to people without javascript. And if it were a large
image, probably very bad on slow computers, but I dunno. I just know I stay
the heck away from bitmaps. *LOL*

Has anyone done this with a real, viewable image?
It's hard to play with a blank 1 pixel image.

Of course, screen caps work no matter what, but the quality isn't always that
great.

--
 
R

Richard Cornford

kaeli said:
That's very odd. A hex image generated by script.

There are not that many browsers that understand this application of the
javascript pseudo protocol:. The image string used is a string
representation of the contents of an image file. XBM images were the
only format that could be used in Netscape < 4.04 because its string
representation was null terminated so image files containing binary, and
so including bytes with zero values, would prematurely terminate the
string definitions (XBM files are ASCII text anyway). These days that
problem is gone (though I wonder about the implications of Unicode in
this context) so in theory other image formats can be used (I have never
tried).

XBM is a two color format so it is very limited. And some browsers do
not know how to interpret it anyway (even assuming they understand the
javascript: SRC).
And of course useless to people without javascript.
And if it were a large image, probably very bad on
slow computers, but I dunno.

It is 40+ bits to the byte storage, with no compression at all. That was
never going to be quick or efficient.

Has anyone done this with a real, viewable image?

It is a means by with a script generated image can be displayed so it
has been used, as the display end or javascript games for one. With XBM
being balck and white, and alternative image file formats requiring
compression (making it too time consuming to go form a script generated
bitmap to a string containing the image data) you won't see this used
often (I don't think I have ever seen it used outside of a javascript
game).
It's hard to play with a blank 1 pixel image.

If you would like to play with some XBM images that you can see try
these two:-

var crossImg = "#define cross_width 32\n"+
"#define cross_height 32\n"+
"static char cross_bits[] = {"+
"0x00, 0x00, 0x01, 0x00, "+
"0x00, 0x00, 0x01, 0x00, "+
"0x00, 0x00, 0x01, 0x00, "+
"0x00, 0x00, 0x01, 0x00, "+
"0x00, 0x00, 0x01, 0x00, "+
"0x00, 0xe0, 0x0f, 0x00, "+
"0x00, 0x18, 0x31, 0x00, "+
"0x00, 0x04, 0x41, 0x00, "+
"0x00, 0x02, 0x81, 0x00, "+
"0x00, 0x01, 0x01, 0x01, "+
"0x80, 0x00, 0x01, 0x02, "+
"0x80, 0x00, 0x01, 0x02, "+
"0x40, 0x00, 0x01, 0x04, "+
"0x40, 0x00, 0x01, 0x04, "+
"0x40, 0x00, 0x01, 0x04, "+
"0xff, 0xff, 0xff, 0xff, "+
"0x40, 0x00, 0x01, 0x04, "+
"0x40, 0x00, 0x01, 0x04, "+
"0x40, 0x00, 0x01, 0x04, "+
"0x80, 0x00, 0x01, 0x02, "+
"0x80, 0x00, 0x01, 0x02, "+
"0x00, 0x01, 0x01, 0x01, "+
"0x00, 0x02, 0x81, 0x00, "+
"0x00, 0x04, 0x41, 0x00, "+
"0x00, 0x18, 0x31, 0x00, "+
"0x00, 0xe0, 0x0f, 0x00, "+
"0x00, 0x00, 0x01, 0x00, "+
"0x00, 0x00, 0x01, 0x00, "+
"0x00, 0x00, 0x01, 0x00, "+
"0x00, 0x00, 0x01, 0x00, "+
"0x00, 0x00, 0x01, 0x00, "+
"0x00, 0x00, 0x01, 0x00 "+
"};"

var trash = "#define trash_width 16\n"+
"#define trash_height 16\n"+
"static char trash_bits[] = {"+
"0x00, 0x01, 0xe0, 0x0f, "+
"0x10, 0x10, 0xf8, 0x3f, "+
"0x10, 0x10, 0x50, 0x15, "+
"0x50, 0x15, 0x50, 0x15, "+
"0x50, 0x15, 0x50, 0x15, "+
"0x50, 0x15, 0x50, 0x15, "+
"0x50, 0x15, 0x10, 0x10, "+
"0xe0, 0x0f, 0x00, 0x00 "+
"};";

Note that low bits in the hex numbers are to the left of the byte when
displayed as pixels, but byte order is correct: left to right, top to
bottom).
Of course, screen caps work no matter what, but
the quality isn't always that great.

As a notion of preventing the saving of images this script generated XBM
idea ranks alongside all George Hester's other ideas; best dismissed out
of hand.

Richard.
 
G

George Hester

Richard Cornford said:
kaeli said:
That's very odd. A hex image generated by script.

There are not that many browsers that understand this application of the
javascript pseudo protocol:. The image string used is a string
representation of the contents of an image file. XBM images were the
only format that could be used in Netscape < 4.04 because its string
representation was null terminated so image files containing binary, and
so including bytes with zero values, would prematurely terminate the
string definitions (XBM files are ASCII text anyway). These days that
problem is gone (though I wonder about the implications of Unicode in
this context) so in theory other image formats can be used (I have never
tried).

XBM is a two color format so it is very limited. And some browsers do
not know how to interpret it anyway (even assuming they understand the
javascript: SRC).
And of course useless to people without javascript.
And if it were a large image, probably very bad on
slow computers, but I dunno.

It is 40+ bits to the byte storage, with no compression at all. That was
never going to be quick or efficient.

Has anyone done this with a real, viewable image?

It is a means by with a script generated image can be displayed so it
has been used, as the display end or javascript games for one. With XBM
being balck and white, and alternative image file formats requiring
compression (making it too time consuming to go form a script generated
bitmap to a string containing the image data) you won't see this used
often (I don't think I have ever seen it used outside of a javascript
game).
It's hard to play with a blank 1 pixel image.

If you would like to play with some XBM images that you can see try
these two:-

var crossImg = "#define cross_width 32\n"+
"#define cross_height 32\n"+
"static char cross_bits[] = {"+
"0x00, 0x00, 0x01, 0x00, "+
"0x00, 0x00, 0x01, 0x00, "+
"0x00, 0x00, 0x01, 0x00, "+
"0x00, 0x00, 0x01, 0x00, "+
"0x00, 0x00, 0x01, 0x00, "+
"0x00, 0xe0, 0x0f, 0x00, "+
"0x00, 0x18, 0x31, 0x00, "+
"0x00, 0x04, 0x41, 0x00, "+
"0x00, 0x02, 0x81, 0x00, "+
"0x00, 0x01, 0x01, 0x01, "+
"0x80, 0x00, 0x01, 0x02, "+
"0x80, 0x00, 0x01, 0x02, "+
"0x40, 0x00, 0x01, 0x04, "+
"0x40, 0x00, 0x01, 0x04, "+
"0x40, 0x00, 0x01, 0x04, "+
"0xff, 0xff, 0xff, 0xff, "+
"0x40, 0x00, 0x01, 0x04, "+
"0x40, 0x00, 0x01, 0x04, "+
"0x40, 0x00, 0x01, 0x04, "+
"0x80, 0x00, 0x01, 0x02, "+
"0x80, 0x00, 0x01, 0x02, "+
"0x00, 0x01, 0x01, 0x01, "+
"0x00, 0x02, 0x81, 0x00, "+
"0x00, 0x04, 0x41, 0x00, "+
"0x00, 0x18, 0x31, 0x00, "+
"0x00, 0xe0, 0x0f, 0x00, "+
"0x00, 0x00, 0x01, 0x00, "+
"0x00, 0x00, 0x01, 0x00, "+
"0x00, 0x00, 0x01, 0x00, "+
"0x00, 0x00, 0x01, 0x00, "+
"0x00, 0x00, 0x01, 0x00, "+
"0x00, 0x00, 0x01, 0x00 "+
"};"

var trash = "#define trash_width 16\n"+
"#define trash_height 16\n"+
"static char trash_bits[] = {"+
"0x00, 0x01, 0xe0, 0x0f, "+
"0x10, 0x10, 0xf8, 0x3f, "+
"0x10, 0x10, 0x50, 0x15, "+
"0x50, 0x15, 0x50, 0x15, "+
"0x50, 0x15, 0x50, 0x15, "+
"0x50, 0x15, 0x50, 0x15, "+
"0x50, 0x15, 0x10, 0x10, "+
"0xe0, 0x0f, 0x00, 0x00 "+
"};";

Note that low bits in the hex numbers are to the left of the byte when
displayed as pixels, but byte order is correct: left to right, top to
bottom).
Of course, screen caps work no matter what, but
the quality isn't always that great.

As a notion of preventing the saving of images this script generated XBM
idea ranks alongside all George Hester's other ideas; best dismissed out
of hand.

Richard.
Never fails always has to do what he can to make George Hester seem like an imbecile. Thanks Richard.

You may not have noticed but the image I used is no bigger then a spacer.gif which is used pretty often on the Net. I can make that image as large as I want in the src and it don't do squat to the size.
 
R

Richard Cornford

George said:
Never fails always has to do what he can to make George
Hester seem like an imbecile. Thanks Richard.

There is no need to thank me, it is no effort.
You may not have noticed but the image I used is no bigger
then a spacer.gif which is used pretty often on the Net.
I can make that image as large as I want in the src and
it don't do squat to the size.

A 1px square transparent GIF is 43 bytes (assuming correct image
optimisation), XBM is bigger than that in unavoidable overheads. And you
will be hard pressed to find a graphical browser that cannot handle GIF
images, which cannot be said for XBM.

Richard.
 

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,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top