You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Joose Vettenranta <jo...@iki.fi> on 2003/10/08 11:19:02 UTC

svg2png dynamic static generation

Hey,

because serializing svg to png is very slow, is it possible to do
somehow next:

-> if picture-{id} exists -> map:read src="picture-{id}"
-> if not -> generate png file from svg and then save it to filesystem
and then show it.

It would make things much faster.

- Joose

-- 
Joose Vettenranta <jo...@iki.fi>  GSM: 044 561 0270
* Always remember that you are unique.
                          Just like everyone else.*

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


Re: svg2png dynamic static generation

Posted by Joose Vettenranta <jo...@intertechnika.com>.
On ke, 2003-10-08 at 13:19, Joose Vettenranta wrote:
> On ke, 2003-10-08 at 13:07, Jorg Heymans wrote:
> > so how did you expect us to know all this ;-) ?
> > Could you please post the pipeline you want to optimize ? That way we 

Also problem is that SVG-template can be very BIG. I'm receiving
svg-template from AD which is exported by photoshop. That SVG file can
be as big as 2.1Mb! The PNG file is just about 200k or something. For
doing things fast, creating pictures only once from SVG to PNG and then
saving PNG to filesystem and showing PNG from there, would be much much
faster. If SVG file is 2.1Mb, it might be the reason batik takes so long
time to render it.

- Joose

-- 
Joose Vettenranta, Intertechnika Oy
E-Mail: joose.vettenranta@intertechnika.com
WWW: http://www.intertechnika.com/
GSM: 044 561 0270

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


Re: svg2png dynamic static generation

Posted by Joose Vettenranta <jo...@iki.fi>.
On ke, 2003-10-08 at 14:05, Jorg Heymans wrote:

Hey,

> I haven't used XSP yet so I don't know exactly where cocoon is failing 
> to cache this pipeline. It caches xsl executions automatically and 
> that's all your pipeline is doing  except for that one xsp.

That on XSP is very simple and is defined like this:


<xsp:page xmlns:xsp="http://apache.org/xsp" language="java"
          xmlns:xsp-session="http://apache.org/xsp/session/2.0"
          xmlns:esql="http://apache.org/cocoon/SQL/v2">
 <osio>
  <xsp:logic>
   String id=parameters.getParameter ("id", null);
  </xsp:logic>
  <esql:connection>
   <esql:pool>XX</esql:pool>
   <esql:execute-query>
    <esql:query>select * from table where
id=<xsp:expr>id</xsp:expr></esql:query>
     <esql:results>
     <esql:row-results>
      <esql:results>
        <esql:row-results>
         <answer>
          <esql:get-columns />
         </answer>
        </esql:row-results>
      </esql:results>
     </esql:row-results>
    </esql:results>
   </esql:execute-query>
  </esql:connection>
 </osio>
</xsp:page>

So nothign special there.

serverpages generator is defined like this:

<map:generator label="content,data"
logger="sitemap.generator.serverpages" name="serverpages" pool-grow="2"
pool-max="64" pool-min="8"
src="org.apache.cocoon.generation.ServerPagesGenerator"/>


- Joose
-- 
Joose Vettenranta <jo...@iki.fi>  GSM: 044 561 0270
* Always remember that you are unique.
                          Just like everyone else.*

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


Re: svg2png dynamic static generation

Posted by Jorg Heymans <jh...@domek.be>.
I haven't used XSP yet so I don't know exactly where cocoon is failing 
to cache this pipeline. It caches xsl executions automatically and 
that's all your pipeline is doing  except for that one xsp.
Looking at the wiki 
http://wiki.cocoondev.org/Wiki.jsp?page=XSPFundamentals , it seems that 
XSP is generated with the serverpagesgenerator. This class (at least in 
2.0.4) implements the Cacheable interface, leaving me puzzled.
You should have a look at core.log to see where exactly if fails to 
retrieve the cached content.

<hint>
Maybe a more xsp-knowledgable person can say something here
</hint>

Jorg

Joose Vettenranta wrote:

>On ke, 2003-10-08 at 13:07, Jorg Heymans wrote:
>  
>
>>so how did you expect us to know all this ;-) ?
>>Could you please post the pipeline you want to optimize ? That way we 
>>can get a better understanding of what components you are using.
>>    
>>
>
>     <map:match pattern="framet/nelio-*.png">
>      <map:aggregate element="data">
>       <map:part src="../../2/xsp/ipsa1.xsp" strip-root="true" />
>       <map:part src="cocoon:/piilotettu/ipsadata-{1}.xml" />
>      </map:aggregate>
><!-- created answers and metadata for the answers -->
>      <map:transform src="style/ipsadata/merge.xsl" />
><!-- transformed metadata and answers to same elements -->
>      <map:transform src="style/ipsadata/count.xsl" label="raw"/>
><!-- does some calculation -->
>      <map:transform src="style/ipsadata/toSVG.xsl" label="raw2"/>
><!-- appends svg template and on top of that draws a polygon -->
>      <map:serialize type="svg2png" />
>     </map:match>
>
>and:
>    <map:match pattern="piilotettu/ipsadata-*.xml">
>     <map:generate type="serverpages" src="xsp/ipsadata.xsp">
>      <map:parameter name="id" value="{1}" />
>     </map:generate>
>     <map:transform src="style/ipsadata/prettySQL.xsl" />
><!--
> changes <"name of the column">value</"name of the column"> to
>         <object name="name of the column>value</object>
>-->
>     <map:serialize type="xml" />
>    </map:match>
>
>The transformation from data to svg is not linear, I have to do some
>math in XSLT (I'm creating 10 edged polygon)
>
>map:part uses .xsp -file,because the same file is used in another part
>of the system, with different purpose.
>
>I don't know is it clear, but the data in the database is not changing
>once inserted. So, SVG-grapchics is the same always. And why I don't
>want to use memory/something caching mechanism, is that after reloading
>tomcat, I want those .png files to be served fast (as in map:read ...).
>
>- Joose
>
>  
>


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


Re: svg2png dynamic static generation

Posted by Joose Vettenranta <jo...@intertechnika.com>.
On ke, 2003-10-08 at 13:07, Jorg Heymans wrote:
> so how did you expect us to know all this ;-) ?
> Could you please post the pipeline you want to optimize ? That way we 
> can get a better understanding of what components you are using.

     <map:match pattern="framet/nelio-*.png">
      <map:aggregate element="data">
       <map:part src="../../2/xsp/ipsa1.xsp" strip-root="true" />
       <map:part src="cocoon:/piilotettu/ipsadata-{1}.xml" />
      </map:aggregate>
<!-- created answers and metadata for the answers -->
      <map:transform src="style/ipsadata/merge.xsl" />
<!-- transformed metadata and answers to same elements -->
      <map:transform src="style/ipsadata/count.xsl" label="raw"/>
<!-- does some calculation -->
      <map:transform src="style/ipsadata/toSVG.xsl" label="raw2"/>
<!-- appends svg template and on top of that draws a polygon -->
      <map:serialize type="svg2png" />
     </map:match>

and:
    <map:match pattern="piilotettu/ipsadata-*.xml">
     <map:generate type="serverpages" src="xsp/ipsadata.xsp">
      <map:parameter name="id" value="{1}" />
     </map:generate>
     <map:transform src="style/ipsadata/prettySQL.xsl" />
<!--
 changes <"name of the column">value</"name of the column"> to
         <object name="name of the column>value</object>
-->
     <map:serialize type="xml" />
    </map:match>

The transformation from data to svg is not linear, I have to do some
math in XSLT (I'm creating 10 edged polygon)

map:part uses .xsp -file,because the same file is used in another part
of the system, with different purpose.

I don't know is it clear, but the data in the database is not changing
once inserted. So, SVG-grapchics is the same always. And why I don't
want to use memory/something caching mechanism, is that after reloading
tomcat, I want those .png files to be served fast (as in map:read ...).

- Joose

-- 
Joose Vettenranta, Intertechnika Oy
E-Mail: joose.vettenranta@intertechnika.com
WWW: http://www.intertechnika.com/
GSM: 044 561 0270

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


Re: svg2png dynamic static generation

Posted by Jorg Heymans <jh...@domek.be>.
so how did you expect us to know all this ;-) ?
Could you please post the pipeline you want to optimize ? That way we 
can get a better understanding of what components you are using.


Joose Vettenranta wrote:

>On ke, 2003-10-08 at 12:48, Jorg Heymans wrote:
>  
>
>>are you describing a caching mechanism here? That's built-in already.
>>What is picture-{id} ?
>>    
>>
>
>I have data in SQL-database. I create svg according to that data. That
>data won't change. picutre-{id} is where id == databases ID. So if that
>file would already be in filesystem, it would be fast to redisplay.
>
>- Joose
>
>
>  
>
>>>Hey,
>>>
>>>because serializing svg to png is very slow, is it possible to do
>>>somehow next:
>>>
>>>-> if picture-{id} exists -> map:read src="picture-{id}"
>>>-> if not -> generate png file from svg and then save it to filesystem
>>>and then show it.
>>>
>>>It would make things much faster.
>>>      
>>>
>
>  
>


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


RE: svg2png dynamic static generation

Posted by Conal Tuohy <co...@paradise.net.nz>.
Joose, if you were thinking of writing a cache for your SVG images, probably
a better idea would to modify the SQLTransformer to make it implement the
Cacheable interface. Then your SVG will be cached by the existing cache.
Maybe you could extend the SQLTransformer so it would execute a
"cache-validity" query before the usual query. Then you could use the result
of this query to implement the getValidity method. Or maybe you could
nominate a particular column in the regular result set as a "timestamp"? So
that the SQL would be executed, the pipeline processor would compare the
timestamp with the cached value, and immediately serve the cached SVG.

Con

> -----Original Message-----
> From: Joose Vettenranta [mailto:joose.vettenranta@intertechnika.com]
> Sent: Wednesday, 8 October 2003 22:52
> To: users@cocoon.apache.org
> Subject: Re: svg2png dynamic static generation
>
>
> On ke, 2003-10-08 at 12:48, Jorg Heymans wrote:
> > are you describing a caching mechanism here? That's
> built-in already.
> > What is picture-{id} ?
>
> I have data in SQL-database. I create svg according to that data. That
> data won't change. picutre-{id} is where id == databases ID.
> So if that
> file would already be in filesystem, it would be fast to redisplay.
>
> - Joose
>
>
> > >Hey,
> > >
> > >because serializing svg to png is very slow, is it possible to do
> > >somehow next:
> > >
> > >-> if picture-{id} exists -> map:read src="picture-{id}"
> > >-> if not -> generate png file from svg and then save it
> to filesystem
> > >and then show it.
> > >
> > >It would make things much faster.
>
> --
> Joose Vettenranta, Intertechnika Oy
> E-Mail: joose.vettenranta@intertechnika.com
> WWW: http://www.intertechnika.com/
> GSM: 044 561 0270
>
> ---------------------------------------------------------------------
> 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: svg2png dynamic static generation

Posted by Joose Vettenranta <jo...@intertechnika.com>.
On ke, 2003-10-08 at 12:48, Jorg Heymans wrote:
> are you describing a caching mechanism here? That's built-in already.
> What is picture-{id} ?

I have data in SQL-database. I create svg according to that data. That
data won't change. picutre-{id} is where id == databases ID. So if that
file would already be in filesystem, it would be fast to redisplay.

- Joose


> >Hey,
> >
> >because serializing svg to png is very slow, is it possible to do
> >somehow next:
> >
> >-> if picture-{id} exists -> map:read src="picture-{id}"
> >-> if not -> generate png file from svg and then save it to filesystem
> >and then show it.
> >
> >It would make things much faster.

-- 
Joose Vettenranta, Intertechnika Oy
E-Mail: joose.vettenranta@intertechnika.com
WWW: http://www.intertechnika.com/
GSM: 044 561 0270

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


Re: svg2png dynamic static generation

Posted by Jorg Heymans <jh...@domek.be>.
are you describing a caching mechanism here? That's built-in already.
What is picture-{id} ?

rgds
Jorg

Joose Vettenranta wrote:

>Hey,
>
>because serializing svg to png is very slow, is it possible to do
>somehow next:
>
>-> if picture-{id} exists -> map:read src="picture-{id}"
>-> if not -> generate png file from svg and then save it to filesystem
>and then show it.
>
>It would make things much faster.
>
>- Joose
>
>  
>


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


Re: svg2png dynamic static generation

Posted by jim basilakis <ji...@ee.unsw.edu.au>.
Thanks for that!!

SourceWritingTransformer certainly seems to be what I am looking for.

So if I wanted to save for example a png file to the filesystem in 
the pipeline I would state:

<map:transform type="write-source">
       <map:parameter name="serializer" value="svg2png"/>
</map:transform>

Has anyone tested this, because I noticed in some comments about the 
SourceWritingTransformer on the Internet that it does not handle
namespaces resulting in invalid XML?

Thanks,
Jim




On Thu, 2003-10-09 at 08:28, Upayavira wrote:
> Check out the SourceWritingTransformer.
> 
> Regards, Upayavira
> 
> jim basilakis wrote:
> 
> >Hi,
> >
> >I am a cocoon newbie and I am using cocoon 2.0.4.
> >I came across the same problem of trying to save a jpeg/png file
> >to the filesystem as part of the course of a pipeline.
> >
> >Any hints as to how to save a generated file (eg. png) to the 
> >filesystem?
> >
> >Thanks,
> >Jim
> > 
> >
> >-----Original Message-----
> >From: Joose Vettenranta [mailto:joose@iki.fi]
> >Sent: Wednesday, 8 October 2003 7:19 PM
> >To: users@cocoon.apache.org
> >Subject: svg2png dynamic static generation
> >
> >
> >Hey,
> >
> >because serializing svg to png is very slow, is it possible to do
> >somehow next:
> >
> >-> if picture-{id} exists -> map:read src="picture-{id}"
> >-> if not -> generate png file from svg and then save it to filesystem
> >and then show it.
> >
> >It would make things much faster.
> >
> >- Joose
> >
> >  
> >
> 
> 
> 
> ---------------------------------------------------------------------
> 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: svg2png dynamic static generation

Posted by Upayavira <uv...@upaya.co.uk>.
Check out the SourceWritingTransformer.

Regards, Upayavira

jim basilakis wrote:

>Hi,
>
>I am a cocoon newbie and I am using cocoon 2.0.4.
>I came across the same problem of trying to save a jpeg/png file
>to the filesystem as part of the course of a pipeline.
>
>Any hints as to how to save a generated file (eg. png) to the 
>filesystem?
>
>Thanks,
>Jim
> 
>
>-----Original Message-----
>From: Joose Vettenranta [mailto:joose@iki.fi]
>Sent: Wednesday, 8 October 2003 7:19 PM
>To: users@cocoon.apache.org
>Subject: svg2png dynamic static generation
>
>
>Hey,
>
>because serializing svg to png is very slow, is it possible to do
>somehow next:
>
>-> if picture-{id} exists -> map:read src="picture-{id}"
>-> if not -> generate png file from svg and then save it to filesystem
>and then show it.
>
>It would make things much faster.
>
>- Joose
>
>  
>



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


RE: svg2png dynamic static generation

Posted by jim basilakis <ji...@ee.unsw.edu.au>.
Hi,

I am a cocoon newbie and I am using cocoon 2.0.4.
I came across the same problem of trying to save a jpeg/png file
to the filesystem as part of the course of a pipeline.

Any hints as to how to save a generated file (eg. png) to the 
filesystem?

Thanks,
Jim
 

-----Original Message-----
From: Joose Vettenranta [mailto:joose@iki.fi]
Sent: Wednesday, 8 October 2003 7:19 PM
To: users@cocoon.apache.org
Subject: svg2png dynamic static generation


Hey,

because serializing svg to png is very slow, is it possible to do
somehow next:

-> if picture-{id} exists -> map:read src="picture-{id}"
-> if not -> generate png file from svg and then save it to filesystem
and then show it.

It would make things much faster.

- Joose

-- 
Joose Vettenranta <jo...@iki.fi>  GSM: 044 561 0270
* Always remember that you are unique.
                          Just like everyone else.*

---------------------------------------------------------------------
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: svg2png dynamic static generation

Posted by Geoff Howard <co...@leverageweb.com>.
Lars Huttar wrote:
> I'm pretty much a cocoon newbie, but here's what I know:
> In your sitemap you can use the resource-exists action to
> take different routes through the pipeline depending on the
> existence of a file.  E.g.:
> 
>       <map:match pattern="picture-*.png">
>         <map:act type="resource-exists">
>           <map:parameter name="url" value="picture-{1}.png" />
>           <!-- If it exists, read it. -->
>           <map:read type="resource"
> 			src="picture-{../1}.png" mime-type="image/png" />
>         </map:act>
>         <!-- Otherwise, generate the png from svg: -->
>         <!-- This part I don't know how to do. :-) Anyone? -->
> 	   <!-- Especially the part about saving the result to a file. -->
>       </map:match>
> 
>>because serializing svg to png is very slow, is it possible to do
>>somehow next:
>>
>>-> if picture-{id} exists -> map:read src="picture-{id}"
>>-> if not -> generate png file from svg and then save it to filesystem
>>and then show it.
>>
>>It would make things much faster.


I missed the first part of the question, but did you know that Cocoon is 
  probably already caching these for you?  What is your current pipeline 
like?

Geoff


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


RE: svg2png dynamic static generation

Posted by Lars Huttar <la...@sil.org>.
I'm pretty much a cocoon newbie, but here's what I know:
In your sitemap you can use the resource-exists action to
take different routes through the pipeline depending on the
existence of a file.  E.g.:

      <map:match pattern="picture-*.png">
        <map:act type="resource-exists">
          <map:parameter name="url" value="picture-{1}.png" />
          <!-- If it exists, read it. -->
          <map:read type="resource"
			src="picture-{../1}.png" mime-type="image/png" />
        </map:act>
        <!-- Otherwise, generate the png from svg: -->
        <!-- This part I don't know how to do. :-) Anyone? -->
	   <!-- Especially the part about saving the result to a file. -->
      </map:match>

> because serializing svg to png is very slow, is it possible to do
> somehow next:
> 
> -> if picture-{id} exists -> map:read src="picture-{id}"
> -> if not -> generate png file from svg and then save it to filesystem
> and then show it.
> 
> It would make things much faster.
> 
> - Joose


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