[jQuery] Re: Possible to retrieve image data via AJAX for display?
Traunic how does raw image data get you anything? Seems you want the data and the image URL via XHR and then dynamically insert your DOM bits (img tag w/ URL from response with some sort of wrapper containing your legend)... I mean, what you are talking about is technically doable (not in all browsers) http://www.kryogenix.org/days/2003/10/18/embedding but I am not sure it gets you anything. No, you haven't read my post carefully enough. I don't want the image's URL because the image *doesn't have* a URL - it's generated by a server-side script. Because I can't retrieve raw image data and legend data in the same request, this now necessitates 2 requests, both of which have common functionality. This to me seems a little odd that two aspects of the same set of information have to be retrieved separately, but then Web development can be like that sometimes ;-) and make sure to check out the link to http://neil.fraser.name/software/img2html/ because that is just sick! Taking your idea to the next demented level Absolutely, I've seen that before, hence I was pretty sure this couldn't be done. What a horrific 'solution'! Although I'm not sure what you think is demented about the idea generically (disgusting 1x1 celled tables aside I mean) - many people have a need of embedding raw image data directly into a Web page, exemplified by the first post mentioning people who are willing to pay money for Web archives - MHTs - to be implemented in Mozilla. Email clients support these archives by using the multipart MIME types. So why not Web browsers? Anyway, as I thought it seems there's no cross-platform mechanism for achieving this, so it's down to making sure 2 similar requests don't unnecessarily repeat redundant code. Thanks for your input on this everyone :-) --rob On 7/24/07, Christof Donat [EMAIL PROTECTED] wrote: Hi, I have a server-side script which generates a graph image given a set of dataset identifiers. Additional datasets are implicitly added server-side too. Currently the image contains the legend, but I'd like to generate the legend in HTML as it'll be more consistent with legends used for tables. The legend contents cannot be determined until partway through graph generation - so I'd like to retrieve both raw image data and legend data via AJAX, build the legend's HTML representation and display the image. I guess you are lokking for something like canvas. Firefox and Safari do support it. I am not shure about Opera, but IE and Konqueror don't. For IE there is at least IECanvas (http://sourceforge.net/projects/iecanvas), which might be of use. You can use JavaScript to put an Image on a canvas and you also have drawing primitives to add Information. Christof -- Rob Desbois Eml: [EMAIL PROTECTED] Tel: 01452 760631 Mob: 07946 705987 There's a whale there's a whale there's a whale fish he cried, and the whale was in full view. ...Then ooh welcome. Ahhh. Ooh mug welcome.
[jQuery] Re: Possible to retrieve image data via AJAX for display?
Rob Desbois wrote: Traunic how does raw image data get you anything? Seems you want the data and the image URL via XHR and then dynamically insert your DOM bits (img tag w/ URL from response with some sort of wrapper containing your legend)... I mean, what you are talking about is technically doable (not in all browsers) http://www.kryogenix.org/days/2003/10/18/embedding but I am not sure it gets you anything. No, you haven't read my post carefully enough. I don't want the image's URL because the image *doesn't have* a URL - it's generated by a server-side script. This cannot be. If you want to load the raw image data via Ajax, there *must* be a URL. But this URL could as well be used as src for the image given that the server-side script sets the proper mime type. --Klaus
[jQuery] Re: Possible to retrieve image data via AJAX for display?
Yes, sorry I didn't phrase my post very well: there is a URL for the image, of course, but I was trying to emphasise that there isn't a URL to an image cached on the server's filesystem to pass back, as I don't want to *permanently* cache the image (or implement a cleverer algorithm - there's no need). I simply want the cached image (or intermediates) to be temporary; the user's session seems the obvious candidate for this type of storage to me. --rob On 7/25/07, Klaus Hartl [EMAIL PROTECTED] wrote: Rob Desbois wrote: Traunic how does raw image data get you anything? Seems you want the data and the image URL via XHR and then dynamically insert your DOM bits (img tag w/ URL from response with some sort of wrapper containing your legend)... I mean, what you are talking about is technically doable (not in all browsers) http://www.kryogenix.org/days/2003/10/18/embedding but I am not sure it gets you anything. No, you haven't read my post carefully enough. I don't want the image's URL because the image *doesn't have* a URL - it's generated by a server-side script. This cannot be. If you want to load the raw image data via Ajax, there *must* be a URL. But this URL could as well be used as src for the image given that the server-side script sets the proper mime type. --Klaus -- Rob Desbois Eml: [EMAIL PROTECTED] Tel: 01452 760631 Mob: 07946 705987 There's a whale there's a whale there's a whale fish he cried, and the whale was in full view. ...Then ooh welcome. Ahhh. Ooh mug welcome.
[jQuery] Re: Possible to retrieve image data via AJAX for display?
Am Mittwoch, 25. Juli 2007 schrieb Rob Desbois: Yes, sorry I didn't phrase my post very well: there is a URL for the image, of course, but I was trying to emphasise that there isn't a URL to an image cached on the server's filesystem to pass back, as I don't want to *permanently* cache the image (or implement a cleverer algorithm - there's no need). I simply want the cached image (or intermediates) to be temporary; the user's session seems the obvious candidate for this type of storage to me. var ctx = $('canvas')[0].getContext(2d); var img = new Image(); img.onload = function() { ctx.drawImage(img,0,0); ctx.beginPath(); ctx.moveTo(30,96); ctx.lineTo(70,66); ctx.lineTo(103,76); ctx.lineTo(170,15); ctx.stroke(); // ... } img.src = /basicImage.png; I am pretty shure that this is what you are looking for. I have the code almost exactly from the first example of http://developer.mozilla.org/en/docs/Canvas_tutorial:Using_images The example should work in Firefox, Safari and Opera. For IE there is IECanvas (http://sourceforge.net/projects/iecanvas). If you really need to care about Konqueror, you can try to mimic the behaviour you need with data URLs. For a refference how this could look like, see PNGlets: http://www.elf.org/pnglets/ There is no really usefull Drawing solution on all Browsers. Changing data URLs lie PNGlet is slow and annoying and IECanvas is slow and can not handle many drawing primitives - it gets slower all the time. There was the possibility in IE 6 to use javascript URLs for images that return monochrome XBM images which could have been colored and combined with filters. Alas MS doesn't support XBM any more, so there is not evan a pita-way left. Christof
[jQuery] Re: Possible to retrieve image data via AJAX for display?
Christof, Thanks for that, but I was really looking to see if there was a browser-independent mechanism, essentially something like the Web archives that IE has supported for years. I think adding components for this would be over-complicating the matter. Thanks anyway. --rob On 7/25/07, Christof Donat [EMAIL PROTECTED] wrote: Am Mittwoch, 25. Juli 2007 schrieb Rob Desbois: Yes, sorry I didn't phrase my post very well: there is a URL for the image, of course, but I was trying to emphasise that there isn't a URL to an image cached on the server's filesystem to pass back, as I don't want to *permanently* cache the image (or implement a cleverer algorithm - there's no need). I simply want the cached image (or intermediates) to be temporary; the user's session seems the obvious candidate for this type of storage to me. var ctx = $('canvas')[0].getContext(2d); var img = new Image(); img.onload = function() { ctx.drawImage(img,0,0); ctx.beginPath(); ctx.moveTo(30,96); ctx.lineTo(70,66); ctx.lineTo(103,76); ctx.lineTo(170,15); ctx.stroke(); // ... } img.src = /basicImage.png; I am pretty shure that this is what you are looking for. I have the code almost exactly from the first example of http://developer.mozilla.org/en/docs/Canvas_tutorial:Using_images The example should work in Firefox, Safari and Opera. For IE there is IECanvas (http://sourceforge.net/projects/iecanvas). If you really need to care about Konqueror, you can try to mimic the behaviour you need with data URLs. For a refference how this could look like, see PNGlets: http://www.elf.org/pnglets/ There is no really usefull Drawing solution on all Browsers. Changing data URLs lie PNGlet is slow and annoying and IECanvas is slow and can not handle many drawing primitives - it gets slower all the time. There was the possibility in IE 6 to use javascript URLs for images that return monochrome XBM images which could have been colored and combined with filters. Alas MS doesn't support XBM any more, so there is not evan a pita-way left. Christof -- Rob Desbois Eml: [EMAIL PROTECTED] Tel: 01452 760631 Mob: 07946 705987 There's a whale there's a whale there's a whale fish he cried, and the whale was in full view. ...Then ooh welcome. Ahhh. Ooh mug welcome.
[jQuery] Re: Possible to retrieve image data via AJAX for display?
Hi, Thanks for that, but I was really looking to see if there was a browser-independent mechanism, No, there isn't. Canvas and IECanvas is the closest you can get. I have done quite some research on that matter for a project where I really could have profited from canvas, but IECanvas was much too slow. You might also spend a thought on Java Applets - at least they work mostly browser-independent. essentially something like the Web archives that IE has supported for years. I never noticed that they ever were browser-independent. Christof
[jQuery] Re: Possible to retrieve image data via AJAX for display?
I never noticed that they ever were browser-independent. I know, that's why I said 'that IE has supported for years' and why I can't use them. Despite the ways there are to do this such as these canvas projects or something big and bulky client-side (Java, Flash possibly, any number of similar technologies), what baffles me most is that you can inject content client-side into many tags: script, style, div, title, all of the things which contain HTML or text. But you can't do that with the specialised tags like img, object and applet. Granted these do not contain HTML, but then neither do script and style. It just seems peculiar to me that there is this mismatch - why wouldn't HTML have the capability to support, e.g. imgGIF89a...binary rubbish.../img? --rob -- Rob Desbois Eml: [EMAIL PROTECTED]
[jQuery] Re: Possible to retrieve image data via AJAX for display?
Rob Desbois wrote: I never noticed that they ever were browser-independent. I know, that's why I said 'that IE has supported for years' and why I can't use them. Despite the ways there are to do this such as these canvas projects or something big and bulky client-side (Java, Flash possibly, any number of similar technologies), what baffles me most is that you can inject content client-side into many tags: script, style, div, title, all of the things which contain HTML or text. But you can't do that with the specialised tags like img, object and applet. Granted these do not contain HTML, but then neither do script and style. It just seems peculiar to me that there is this mismatch - why wouldn't HTML have the capability to support, e.g. imgGIF89a...binary rubbish.../img? It does, using the data URI scheme, I just remembered to have read about it somewhere...: img src=data:image/png;base64, iVBORw0KGgoNSUhEUgoKCAYAAACNMs+9BGdBTUEAALGP C/xhBQlwSFlzAAALEwAACxMBAJqcGAd0SU1FB9YGARc5KB0XV+IA AAAddEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIFRoZSBHSU1Q72QlbgAAAF1J REFUGNO9zL0NglAAxPEfdLTs4BZM4DIO4C7OwQg2JoQ9LE1exdlYvBBeZ7jq ch9//q1uH4TLzw4d6+ErXMMcXuHWxId3KOETnnXXV6MJpcq2MLaI97CER3N0 vr4MkhoXe0rZigBJRU5ErkJggg== alt=Red dot / Of course it isn't supported in IE... http://en.wikipedia.org/wiki/Data:_URI_scheme --Klaus
[jQuery] Re: Possible to retrieve image data via AJAX for display?
Hi, I believe the ctx variable should be: var ctx = $('canvas')[0].getContext(2d); I was expecting that a canvas tag exists on the page. If it doesn't it should better be something like this: var ctx = $('canvas').appendto('body')[0].getContext(2d); Christof
[jQuery] Re: Possible to retrieve image data via AJAX for display?
JK, Thanks but no - that's my alternative. Dan, Absolutely, please do tell me if I am! I have a server-side script which generates a graph image given a set of dataset identifiers. Additional datasets are implicitly added server-side too. Currently the image contains the legend, but I'd like to generate the legend in HTML as it'll be more consistent with legends used for tables. The legend contents cannot be determined until partway through graph generation - so I'd like to retrieve both raw image data and legend data via AJAX, build the legend's HTML representation and display the image. Otherwise, I'll use an AJAX request to return the legend data, and cache the intermediate step so that when I insert the img tag for the graph, the generating script doesn't need to repeat the first part. What do you think? --rob On 7/23/07, Dan G. Switzer, II [EMAIL PROTECTED] wrote: Rob, I have a feeling the answer is a flat 'no', but want to check: is it possible for an AJAX request to retrieve binary image data (e.g. raw GIF) and display that on the page? Can you describe the *exact* effect your trying to achieve? Why do you think you need to load binary image data via AJAX? I'm asking just to make sure you're not barking up the wrong tree... -Dan -- Rob Desbois Eml: [EMAIL PROTECTED] Tel: 01452 760631 Mob: 07946 705987 There's a whale there's a whale there's a whale fish he cried, and the whale was in full view. ...Then ooh welcome. Ahhh. Ooh mug welcome.
[jQuery] Re: Possible to retrieve image data via AJAX for display?
how does raw image data get you anything? Seems you want the data and the image URL via XHR and then dynamically insert your DOM bits (img tag w/ URL from response with some sort of wrapper containing your legend)... I mean, what you are talking about is technically doable (not in all browsers) http://www.kryogenix.org/days/2003/10/18/embedding but I am not sure it gets you anything. -wade On Jul 24, 3:59 am, Rob Desbois [EMAIL PROTECTED] wrote: JK, Thanks but no - that's my alternative. Dan, Absolutely, please do tell me if I am! I have a server-side script which generates a graph image given a set of dataset identifiers. Additional datasets are implicitly added server-side too. Currently the image contains the legend, but I'd like to generate the legend in HTML as it'll be more consistent with legends used for tables. The legend contents cannot be determined until partway through graph generation - so I'd like to retrieve both raw image data and legend data via AJAX, build the legend's HTML representation and display the image. Otherwise, I'll use an AJAX request to return the legend data, and cache the intermediate step so that when I insert the img tag for the graph, the generating script doesn't need to repeat the first part. What do you think? --rob On 7/23/07, Dan G. Switzer, II [EMAIL PROTECTED] wrote: Rob, I have a feeling the answer is a flat 'no', but want to check: is it possible for an AJAX request to retrieve binary image data (e.g. raw GIF) and display that on the page? Can you describe the *exact* effect your trying to achieve? Why do you think you need to load binary image data via AJAX? I'm asking just to make sure you're not barking up the wrong tree... -Dan -- Rob Desbois Eml: [EMAIL PROTECTED] Tel: 01452 760631 Mob: 07946 705987 There's a whale there's a whale there's a whale fish he cried, and the whale was in full view. ...Then ooh welcome. Ahhh. Ooh mug welcome.
[jQuery] Re: Possible to retrieve image data via AJAX for display?
a more recent post about this topic http://rifers.org/blogs/gbevin/2005/4/11/embedding_images_inside_html and make sure to check out the link to http://neil.fraser.name/software/img2html/ because that is just sick! Taking your idea to the next demented level -w On Jul 24, 2:20 pm, traunic [EMAIL PROTECTED] wrote: how does raw image data get you anything? Seems you want the data and the image URL via XHR and then dynamically insert your DOM bits (img tag w/ URL from response with some sort of wrapper containing your legend)... I mean, what you are talking about is technically doable (not in all browsers)http://www.kryogenix.org/days/2003/10/18/embedding but I am not sure it gets you anything. -wade On Jul 24, 3:59 am, Rob Desbois [EMAIL PROTECTED] wrote: JK, Thanks but no - that's my alternative. Dan, Absolutely, please do tell me if I am! I have a server-side script which generates a graph image given a set of dataset identifiers. Additional datasets are implicitly added server-side too. Currently the image contains the legend, but I'd like to generate the legend in HTML as it'll be more consistent with legends used for tables. The legend contents cannot be determined until partway through graph generation - so I'd like to retrieve both raw image data and legend data via AJAX, build the legend's HTML representation and display the image. Otherwise, I'll use an AJAX request to return the legend data, and cache the intermediate step so that when I insert the img tag for the graph, the generating script doesn't need to repeat the first part. What do you think? --rob On 7/23/07, Dan G. Switzer, II [EMAIL PROTECTED] wrote: Rob, I have a feeling the answer is a flat 'no', but want to check: is it possible for an AJAX request to retrieve binary image data (e.g. raw GIF) and display that on the page? Can you describe the *exact* effect your trying to achieve? Why do you think you need to load binary image data via AJAX? I'm asking just to make sure you're not barking up the wrong tree... -Dan -- Rob Desbois Eml: [EMAIL PROTECTED] Tel: 01452 760631 Mob: 07946 705987 There's a whale there's a whale there's a whale fish he cried, and the whale was in full view. ...Then ooh welcome. Ahhh. Ooh mug welcome.
[jQuery] Re: Possible to retrieve image data via AJAX for display?
Hi, I have a server-side script which generates a graph image given a set of dataset identifiers. Additional datasets are implicitly added server-side too. Currently the image contains the legend, but I'd like to generate the legend in HTML as it'll be more consistent with legends used for tables. The legend contents cannot be determined until partway through graph generation - so I'd like to retrieve both raw image data and legend data via AJAX, build the legend's HTML representation and display the image. I guess you are lokking for something like canvas. Firefox and Safari do support it. I am not shure about Opera, but IE and Konqueror don't. For IE there is at least IECanvas (http://sourceforge.net/projects/iecanvas), which might be of use. You can use JavaScript to put an Image on a canvas and you also have drawing primitives to add Information. Christof
[jQuery] Re: Possible to retrieve image data via AJAX for display?
Rob, I have a feeling the answer is a flat 'no', but want to check: is it possible for an AJAX request to retrieve binary image data (e.g. raw GIF) and display that on the page? Can you describe the *exact* effect your trying to achieve? Why do you think you need to load binary image data via AJAX? I'm asking just to make sure you're not barking up the wrong tree... -Dan