You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by beyaNet Consultancy <be...@ntlworld.com> on 2004/02/16 08:46:26 UTC

Referencing inline images - How to?

Hi,
so far I have been making reference to images via my sitemap as   
standard:

			<map:match pattern="*.jpg">
				<map:read mine-type="text/jpeg" src="images/{1}.jpg" />
			</map:match>

As I am now using inline images I have changed my sitemap to the  
following:

			<map:match pattern="artist1">
				<map:read mine-type="image/jpeg" src="artist1" />
			</map:match>

My image structure is:

			<xsp:element name="object">
				<xsp:attribute name="id">artist1</xsp:attribute>
				<xsp:attribute name="width">200</xsp:attribute>
				<xsp:attribute name="height">200</xsp:attribute>
				<xsp:attribute name="type">image/jpeg</xsp:attribute>
				<xsp:attribute  
name="data">data:image/jpeg;base64,<xsp:expr>base64-string</xsp:expr></ 
xsp:attribute>
			</xsp:element>

When viewed in the browser the image is broken, i.e. it cannot find it.  
How do i resolve this? Do I reference back to the xsl page the image  
sits in?

The sitemap structure for the page the image sits in is:

			<map:generate type="serverpages" src="xsp/{../1}.xsp" />
			<map:transform type="xslt" src="style/frame-page.xsl" />
			<map:serialize type="html"/>

many thanks in advance

Re: Referencing inline images - How to?

Posted by Simon Mieth <si...@t-online.de>.
On Tue, 17 Feb 2004 14:25:13 +0000
beyaNet Consultancy <be...@ntlworld.com> wrote:

> Simon,
> I am doing something wrong here. explain to me exactly what attributes  
> should be made available in the image tag? I think it would be better  
> if you just show me the code you are using to generate the image tag.  
> Do you mean

<xsp:attribute name="xlink:href">data:image/jpeg;base64

Hi,
take this and put the xmlns:xlink=".." to the <image>-element or document-root,
where other xmlns are defined. But i'm not sure how to handle namespace-attributes
correct in xsp, try it. Maybe you can find it in the docs.

<xsp:attribute name="xlink:href">data:image/jpeg;base64

Best Regards,
Simon

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Referencing inline images - How to?

Posted by beyaNet Consultancy <be...@ntlworld.com>.
Simon,
I am doing something wrong here. explain to me exactly what attributes  
should be made available in the image tag? I think it would be better  
if you just show me the code you are using to generate the image tag.  
Do you mean

<xsp:attribute name="xlink">http://www.w3.org/1999/xlink
<xsp:attribute name="href">data:image/jpeg;base64
or
<xsp:attribute name="xmlns:xlink">http://www.w3.org/1999/xlink
<xsp:attribute name="xlink:href">data:image/jpeg;base64

I have changed the src attribute to href as you stated in your email,  
and now nothing works. href is not a supported attribute of the img  
tag!!??
Can you show me the code you are using to generate the image in your  
xsp page. I do the following:

						<xsp:attribute  
name="xmlns:xlink">http://www.w3.org/1999/xlink</xsp:attribute>
						<xsp:attribute  
name="xlink:href">data:image/jpeg;base64,<xsp:expr>newPhoto1</xsp: 
expr></xsp:attribute>
						<xsp:attribute name="width">300</xsp:attribute>
						<xsp:attribute name="height">300</xsp:attribute>

but I am now getting an xml error on xlink

many thanks in advance
On 17 Feb 2004, at 09:38, Simon Mieth wrote:

> On Mon, 16 Feb 2004 22:54:09 +0000
> beyaNet Consultancy <be...@ntlworld.com> wrote:
>
>> Simon,
>> could you just confirm to me that i am using the correct
>> syntax
>>
>> sitemap:
>> 		<map:serializers default="html">
>> 			<map:serializer name="svg2jpeg"
>> src="org.apache.cocoon.serialization.SVGSerializer"
>> mime-type="image/jpeg"
>> logger="sitemap.serializer.svg2jpeg"/>
>> 		</map:serializers>
>> 	
>
>
>
> Hi,
>
> it  looks ok.  You can try to use the svg2png serializer
> (you must only change the type="" in the serializer
> section). Try our svg with an static image from filesystem
> (href:xlink="file:///my/image/here/test.jpg").
>
> Argh, i see now you use the src-attribute in image-element,
> use <image
> xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="data:
> image/jpeg;base64,.." width....  />.
>
> Regards,
>
> Simon
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>

Re: Referencing inline images - How to?

Posted by Simon Mieth <si...@t-online.de>.
On Mon, 16 Feb 2004 22:54:09 +0000
beyaNet Consultancy <be...@ntlworld.com> wrote:

> Simon,
> could you just confirm to me that i am using the correct
> syntax
> 
> sitemap:
> 		<map:serializers default="html">
> 			<map:serializer name="svg2jpeg"  
> src="org.apache.cocoon.serialization.SVGSerializer"  
> mime-type="image/jpeg"
> logger="sitemap.serializer.svg2jpeg"/>
> 		</map:serializers>
> 	        



Hi,

it  looks ok.  You can try to use the svg2png serializer
(you must only change the type="" in the serializer
section). Try our svg with an static image from filesystem
(href:xlink="file:///my/image/here/test.jpg").

Argh, i see now you use the src-attribute in image-element,
use <image
xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="data:
image/jpeg;base64,.." width....  />. 

Regards,

Simon

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Referencing inline images - How to?

Posted by beyaNet Consultancy <be...@ntlworld.com>.
Simon,
could you just confirm to me that i am using the correct syntax

sitemap:
		<map:serializers default="html">
			<map:serializer name="svg2jpeg"  
src="org.apache.cocoon.serialization.SVGSerializer"  
mime-type="image/jpeg" logger="sitemap.serializer.svg2jpeg"/>
		</map:serializers>
	        
........................................................................ 
.................................................................
		<map:match pattern="frame/*.jpg">
			<map:generate type="serverpages" src="xsp/artist-details.xsp" />
			<map:serialize type="svg2jpeg"/>
		</map:match>

		<xsp:element name="image">
			<xsp:attribute name="id">artist1</xsp:attribute>
			<xsp:attribute name="width">300</xsp:attribute>
			<xsp:attribute name="height">300</xsp:attribute>
			<xsp:attribute  
name="src">data:image/jpeg;base64,<xsp:expr>newPhoto1</xsp:expr></xsp: 
attribute>
		</xsp:element>

many thanks in advance
On 16 Feb 2004, at 22:26, Simon Mieth wrote:

> On Mon, 16 Feb 2004 22:04:03 +0000
> beyaNet Consultancy <be...@ntlworld.com> wrote:
>
>> Simon,I can save the image in Netscape and then load it up
>> into IE without any problems. Does IE support
>> src="data:image/jpeg;base64 ???
> Hi,
>
> The serializer create an jpeg image. I have there
> data:image/png;base64 , but i think thats not the problem.
> The serializer write an jpeg-image byte-stream to the
> browser. Maybe there is the problem. Can you look into the
> logs (tomcat too if you use it)?
>
> Best Regards,
>
> Simon
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>

Re: Referencing inline images - How to?

Posted by Simon Mieth <si...@t-online.de>.
On Mon, 16 Feb 2004 22:04:03 +0000
beyaNet Consultancy <be...@ntlworld.com> wrote:

> Simon,I can save the image in Netscape and then load it up
> into IE without any problems. Does IE support
> src="data:image/jpeg;base64 ???
Hi,

The serializer create an jpeg image. I have there
data:image/png;base64 , but i think thats not the problem.
The serializer write an jpeg-image byte-stream to the
browser. Maybe there is the problem. Can you look into the
logs (tomcat too if you use it)?

Best Regards,

Simon

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Referencing inline images - How to?

Posted by beyaNet Consultancy <be...@ntlworld.com>.
Simon,I can save the image in Netscape and then load it up into IE 
without any problems. Does IE support src="data:image/jpeg;base64 ???
On 16 Feb 2004, at 21:48, Simon Mieth wrote:

> Hi,
>
>
> On Mon, 16 Feb 2004 16:51:27 +0000
> beyaNet Consultancy <be...@ntlworld.com> wrote:
>
>> Simon,
>> thanks for the tip you gave earlier. It works fine in
>> Netscape but is a  broken image in IE. What am I doing
>> wrong?
>>
>> My xsp looks like this:
>>
>> 			byte[] photoa = artist.getArtistPhoto1();
>> 	
>> 			<!-- base64 encode byte array -->
>> 			String newPhoto =
>> 			Base64.encodeBytes(photoa);
>>
>> 			<!-- remove spaces from string -->
>> 	        String newPhoto1 =
>> 	        spaceRemover.trim(newPhoto);
>
> I think you dont need this. If your byte-array holds the
> image, then the encoded String hold this bytes without
> erasable whitespaces and if there a Whitespace it should be
> there. ;-)
>
>
>
>
>> 			</xsp:logic>
>> 		     <page>
>> 		    ........
>> 			<svg width="200" height="200">
>> 			<xsp:element name="image">
>> 				<xsp:attribute
>> 				name="width">200</xsp:attribute><xsp:attri
>> 				bute
>> 				name="height">200</xsp:attribute><xsp:attr
>> 				ibute
>> name="src">data:image/jpeg;base64,<xsp:expr>newPhoto1</xs
>> p:expr></xsp: attribute>
>> 			</xsp:element>
>> 			</svg>
>> 			</page>
>>
>> My sitemap looks like this:
>>
>> 			<map:match pattern="frame/*.jpg">
>> 				<map:generate type="serverpages"
>> 				src="xsp/artist-details.xsp"
>> 				/><map:serialize type="svg2jpeg"/>
>> 			</map:match>
>>
>> many thanks in advance
>>
>
> Can you save the image in Netscape or use something like
> wget and open in IE with the same error?
> You can test the svg with a static image from the
> filesystem?
>
> I use encode images with filter, that works in IE. So i dont
> now where the problem is. I remember there were problems
> with IE and the svg/jpeg/png serializer, but i thing this is
> solved. Maybe the mail-archive can help you.
>
>
> Best Regards,
>
> Simon
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Referencing inline images - How to?

Posted by Simon Mieth <si...@t-online.de>.
Hi,


On Mon, 16 Feb 2004 16:51:27 +0000
beyaNet Consultancy <be...@ntlworld.com> wrote:

> Simon,
> thanks for the tip you gave earlier. It works fine in
> Netscape but is a  broken image in IE. What am I doing
> wrong?
> 
> My xsp looks like this:
> 
> 			byte[] photoa = artist.getArtistPhoto1();
> 	
> 			<!-- base64 encode byte array -->
> 			String newPhoto =
> 			Base64.encodeBytes(photoa);
> 
> 			<!-- remove spaces from string -->
> 	        String newPhoto1 =
> 	        spaceRemover.trim(newPhoto);

I think you dont need this. If your byte-array holds the
image, then the encoded String hold this bytes without
erasable whitespaces and if there a Whitespace it should be
there. ;-)




> 			</xsp:logic>
> 		     <page>
> 		    ........
> 			<svg width="200" height="200">
> 			<xsp:element name="image">
> 				<xsp:attribute
> 				name="width">200</xsp:attribute><xsp:attri
> 				bute
> 				name="height">200</xsp:attribute><xsp:attr
> 				ibute  
> name="src">data:image/jpeg;base64,<xsp:expr>newPhoto1</xs
> p:expr></xsp: attribute>
> 			</xsp:element>
> 			</svg>
> 			</page>
> 
> My sitemap looks like this:
> 
> 			<map:match pattern="frame/*.jpg">
> 				<map:generate type="serverpages"
> 				src="xsp/artist-details.xsp"
> 				/><map:serialize type="svg2jpeg"/>
> 			</map:match>
> 
> many thanks in advance
> 

Can you save the image in Netscape or use something like
wget and open in IE with the same error?
You can test the svg with a static image from the
filesystem?

I use encode images with filter, that works in IE. So i dont
now where the problem is. I remember there were problems
with IE and the svg/jpeg/png serializer, but i thing this is
solved. Maybe the mail-archive can help you.


Best Regards,

Simon


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Referencing inline images - How to?

Posted by beyaNet Consultancy <be...@ntlworld.com>.
Simon,
thanks for the tip you gave earlier. It works fine in Netscape but is a  
broken image in IE. What am I doing wrong?

My xsp looks like this:

			byte[] photoa = artist.getArtistPhoto1();
	
			<!-- base64 encode byte array -->
			String newPhoto = Base64.encodeBytes(photoa);

			<!-- remove spaces from string -->
	        String newPhoto1 = spaceRemover.trim(newPhoto);
			</xsp:logic>

		     <page>
		    ........
			<svg width="200" height="200">
			<xsp:element name="image">
				<xsp:attribute name="width">200</xsp:attribute>
				<xsp:attribute name="height">200</xsp:attribute>
				<xsp:attribute  
name="src">data:image/jpeg;base64,<xsp:expr>newPhoto1</xsp:expr></xsp: 
attribute>
			</xsp:element>
			</svg>
			</page>

My sitemap looks like this:

			<map:match pattern="frame/*.jpg">
				<map:generate type="serverpages" src="xsp/artist-details.xsp" />
				<map:serialize type="svg2jpeg"/>
			</map:match>

many thanks in advance


On 16 Feb 2004, at 09:36, Simon Mieth wrote:

> <svg width="...." height="......">

Re: Referencing inline images - How to?

Posted by Simon Mieth <si...@t-online.de>.
On Mon, 16 Feb 2004 07:46:26 +0000
beyaNet Consultancy <be...@ntlworld.com> wrote:

> Hi,
> so far I have been making reference to images via my
> sitemap as   standard:
> 
> 			<map:match pattern="*.jpg">
> 				<map:read mine-type="text/jpeg"
> 				src="images/{1}.jpg" />
> 			</map:match>
> 
> As I am now using inline images I have changed my sitemap
> to the  following:
> 
> 			<map:match pattern="artist1">
> 				<map:read mine-type="image/jpeg"
> 				src="artist1" />
> 			</map:match>
> 
> My image structure is:
> 
> 			<xsp:element name="object">
> 				<xsp:attribute
> 				name="id">artist1</xsp:attribute><xsp:attr
> 				ibute
> 				name="width">200</xsp:attribute><xsp:attri
> 				bute
> 				name="height">200</xsp:attribute><xsp:attr
> 				ibute
> 				name="type">image/jpeg</xsp:attribute><xsp
> 				:attribute  
> name="data">data:image/jpeg;base64,<xsp:expr>base64-strin
> g</xsp:expr></ xsp:attribute>
> 			</xsp:element>
> 
> When viewed in the browser the image is broken, i.e. it
> cannot find it.  How do i resolve this? Do I reference
> back to the xsl page the image  sits in?
> 
> The sitemap structure for the page the image sits in is:
> 
> 			<map:generate type="serverpages"
> 			src="xsp/{../1}.xsp" /><map:transform
> 			type="xslt" src="style/frame-page.xsl"
> 			/><map:serialize type="html"/>
> 
> many thanks in advance

Hi,

the map:read can only read images direct. If you want to get
your images from your db, then you have to create an own
reader (java-component, no xsp) that query your db and write
the image to the reponse-stream direct.

But i see you have the images base64 endcoded, isnt it?
You can now simple create a pipeline like this.

<map:match pattern="*.jpg">
   <map:generate type="serverpages" src="my.xsp" /> 
<!-- your xsp, that get the images from db and make a
svg here-->   
   <map:serialize type="svg2jpeg"/>
</map:match>

Your XSP should give a SVG-XML-document like:

<svg width="...." height="......">
<image xmlns:xlink="http://www.w3.org/1999/xlink
xlink:href="data:image/png;base64,!!!your base64 string
here !!!"/>
</svg>


Best Regards,

Simon










---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org