Image rendering (image creation / manipulation)
Hi, I am thinking of creating a way of doing image rendering through sling and thought I would first check with the community as to whether this has been thought of, and whether there are any thoughts on how this may work. Thoughts that I have had as to what this can be used for are (among others): * scaling * rotation * watermarking * layering (i.e. use one image as background another as foreground) * format changing e.g. png -> jpg * quality change (to reduce size of say jpg) So say /img/test is a png image (with sling:resourceType = "abc/def") and I requested /img/test.jpg that something would reformat the image from png to jpg. If I requested /img/test.small.jpg the image would be reduced and the format changed. So I guess the most "basic" way of doing this would be to write a servlet that specifically did a certain type of image creation / manipulation. But this seems a little tedious to me, and not very customizable by someone in the future. Another thought would be that something like JSP or Groovy would be used to do the image manipulation and there was a script that did this say: /apps/abc/def/jpg.jsp One of the issues I see with this is that it would require the imageio and jai libraries to be added somewhere that would then be visible to this even though in most cases nobody would use jsp for this etc. Also I don't think this would be that easy for someone who doesn't know a reasonable amount about jai and imageio. What I have been thinking about and what I am proposing is another scripting bundle that is specifically used for image creation and manipulation. This would then have some sort of source (still thinking about how this would work) that would define the processing to perform. Initial thoughts are something along the lines of a set of parameterized JAI operators, e.g. SubsampleAverageDescriptor, UnsharpMaskDescriptor, AddDescriptor. Maybe not strictly a script either but a set of nodes in the repository which makes up the "script"? Would be interested in any feedback, other options etc. before I start design / development of this. Cheers Bryce
Re: Image rendering (image creation / manipulation)
On 7 Jul 2008, at 14:48, Bryce Ewing wrote: One of the issues I see with this is that it would require the imageio and jai libraries to be added somewhere that would then be visible to this even though in most cases nobody would use jsp for this etc. Also I don't think this would be that easy for someone who doesn't know a reasonable amount about jai and imageio. Our experience with adding image manipulation capabilities to our product has been that JAI is possible to use, but in practise requires too much memory and / or is too slow for real usage. You be better off writing a wrapper around the "convert" utility of ImageMagick. It would be handy to have an open source utility library that would be easy to "plug into" sling, with different backends for image manipulation implemented either with JAI or wrappers as described. -- Torgeir Veimo [EMAIL PROTECTED]
Re: Image rendering (image creation / manipulation)
Hi Bryce, On Mon, Jul 7, 2008 at 6:48 AM, Bryce Ewing <[EMAIL PROTECTED]> wrote: > ...I am thinking of creating a way of doing image rendering through sling and > thought I would first check with the community as to whether this has been > thought of, and whether there are any thoughts on how this may work We don't have any concrete plans at the moment, but what you suggest looks useful. >... Thoughts that I have had as to what this can be used for are (among >others): > * scaling > * rotation > * watermarking > * layering (i.e. use one image as background another as foreground) > * format changing e.g. png -> jpg > * quality change (to reduce size of say jpg)... Creating a java component (in a bundle) that implements these operations would make that usable from any scripting language and servlet, for example: // myResourceType.png script var s = sling.getService(org.apache.sling.imaging.Processor); var p = s.getImageProcessor(); if(request.selectors[0] == "small") { p.scale = 0.5; } else { p.scale = 1; } p.rotation = 90; p.outputFormat = png; p.watermark = currentNode.getPath() + ".watermark.png"; p.metadata.title = currentNode.title; p.render(currentNode,response); And the image processor might also provide a simple way to store the output in the repository, as an option to dynamic rendering. > ...So say /img/test is a png image (with sling:resourceType = "abc/def") and I > requested /img/test.jpg that something would reformat the image from png to > jpg. If I requested /img/test.small.jpg the image would be reduced and the > format changed... Scripting, as above, will allow you to use the "small" selector easily. > ...So I guess the most "basic" way of doing this would be to write a servlet > that specifically did a certain type of image creation / manipulation As you also mention, a service that provides an image processor component is more flexible. > ...One of the issues I see with this is that it would require the imageio and > jai libraries to be added somewhere that would then be visible to this even > though in most cases nobody would use jsp for this etc. Also I don't think > this would be that easy for someone who doesn't know a reasonable amount > about jai and imageio OSGi allows you to "hide" those libraries inside a bundle, and expose just the service interface. I'm not familiar with those libraries, but it's certainly possible to write a facade that exposes image operations so that they can be used as above, taking a Node as input, as long as the Node contains image file data. At least for basic usage, and maybe provide a more direct access to the libraries for advanced use. > ...What I have been thinking about and what I am proposing is another > scripting > bundle that is specifically used for image creation and manipulation. This > would then have some sort of source (still thinking about how this would > work) that would define the processing to perform. Initial thoughts are > something along the lines of a set of parameterized JAI operators, e.g. > SubsampleAverageDescriptor, UnsharpMaskDescriptor, AddDescriptor I also thought about an image processing language at first, but I think the above example where a script drives an image processor component is more flexible and requires less work to implement. And also allows offline processing of images, where repository events trigger java code or scripts that process and store ready to use images. > ...Would be interested in any feedback, other options etc. before I start > design / development of this Thanks for your suggestions, and I'm sure we'll do our best to help if you're willing to work on this. I'm sure you notice my "subtle" hints to people who might contribute useful stuff to Sling ;-) Considering that the core is fairly stable now, and that important functions like what you describe are still missing, I think it's a really good time to get involved. -Bertrand
Re: Image rendering (image creation / manipulation)
On my future todo list was to see how well I can integreate EMB JSR 86 with Sling, especially the MFB beans can serve as libraries for image manipulation and watermarking and a whole lot more. Please have a look at http://www.alphaworks.ibm.com/tech/emb Ransford Segu-Baffoe [EMAIL PROTECTED] https://serenade.dev.java.net/ http://www.noqturnalmediasystems.com/ --- On Mon, 7/7/08, Bertrand Delacretaz <[EMAIL PROTECTED]> wrote: From: Bertrand Delacretaz <[EMAIL PROTECTED]> Subject: Re: Image rendering (image creation / manipulation) To: sling-dev@incubator.apache.org Date: Monday, July 7, 2008, 3:15 AM Hi Bryce, On Mon, Jul 7, 2008 at 6:48 AM, Bryce Ewing <[EMAIL PROTECTED]> wrote: > ...I am thinking of creating a way of doing image rendering through sling and > thought I would first check with the community as to whether this has been > thought of, and whether there are any thoughts on how this may work We don't have any concrete plans at the moment, but what you suggest looks useful. >... Thoughts that I have had as to what this can be used for are (among others): > * scaling > * rotation > * watermarking > * layering (i.e. use one image as background another as foreground) > * format changing e.g. png -> jpg > * quality change (to reduce size of say jpg)... Creating a java component (in a bundle) that implements these operations would make that usable from any scripting language and servlet, for example: // myResourceType.png script var s = sling.getService(org.apache.sling.imaging.Processor); var p = s.getImageProcessor(); if(request.selectors[0] == "small") { p.scale = 0.5; } else { p.scale = 1; } p.rotation = 90; p.outputFormat = png; p.watermark = currentNode.getPath() + ".watermark.png"; p.metadata.title = currentNode.title; p.render(currentNode,response); And the image processor might also provide a simple way to store the output in the repository, as an option to dynamic rendering. > ...So say /img/test is a png image (with sling:resourceType = "abc/def") and I > requested /img/test.jpg that something would reformat the image from png to > jpg. If I requested /img/test.small.jpg the image would be reduced and the > format changed... Scripting, as above, will allow you to use the "small" selector easily. > ...So I guess the most "basic" way of doing this would be to write a servlet > that specifically did a certain type of image creation / manipulation As you also mention, a service that provides an image processor component is more flexible. > ...One of the issues I see with this is that it would require the imageio and > jai libraries to be added somewhere that would then be visible to this even > though in most cases nobody would use jsp for this etc. Also I don't think > this would be that easy for someone who doesn't know a reasonable amount > about jai and imageio OSGi allows you to "hide" those libraries inside a bundle, and expose just the service interface. I'm not familiar with those libraries, but it's certainly possible to write a facade that exposes image operations so that they can be used as above, taking a Node as input, as long as the Node contains image file data. At least for basic usage, and maybe provide a more direct access to the libraries for advanced use. > ...What I have been thinking about and what I am proposing is another scripting > bundle that is specifically used for image creation and manipulation. This > would then have some sort of source (still thinking about how this would > work) that would define the processing to perform. Initial thoughts are > something along the lines of a set of parameterized JAI operators, e.g. > SubsampleAverageDescriptor, UnsharpMaskDescriptor, AddDescriptor I also thought about an image processing language at first, but I think the above example where a script drives an image processor component is more flexible and requires less work to implement. And also allows offline processing of images, where repository events trigger java code or scripts that process and store ready to use images. > ...Would be interested in any feedback, other options etc. before I start > design / development of this Thanks for your suggestions, and I'm sure we'll do our best to help if you're willing to work on this. I'm sure you notice my "subtle" hints to people who might contribute useful stuff to Sling ;-) Considering that the core is fairly stable now, and that important functions like what you describe are still missing, I think it's a really good time to get involved. -Bertrand
Re: Image rendering (image creation / manipulation)
Hi Bertrand, After having a bit of time to think about this I think your suggestion to have a java component to do this would be a good idea, and if then there is a specific image scripting language built around that then so be it. Have spent a bit of time over the past few days looking into and trying to integrate JAI and ImageIO into a bundle built by maven etc. etc. (and half the time spent beating my head against a wall). I am not sure how well using these libraries will work due to having to download them from Sun's site rather than automatically getting them from a maven repository. So this has set me back a bit. Bertrand Delacretaz wrote: Creating a java component (in a bundle) that implements these operations would make that usable from any scripting language and servlet, for example: // myResourceType.png script var s = sling.getService(org.apache.sling.imaging.Processor); var p = s.getImageProcessor(); if(request.selectors[0] == "small") { p.scale = 0.5; } else { p.scale = 1; } p.rotation = 90; p.outputFormat = png; p.watermark = currentNode.getPath() + ".watermark.png"; p.metadata.title = currentNode.title; p.render(currentNode,response); And the image processor might also provide a simple way to store the output in the repository, as an option to dynamic rendering. ... Thanks for your suggestions, and I'm sure we'll do our best to help if you're willing to work on this. I'm sure you notice my "subtle" hints to people who might contribute useful stuff to Sling ;-) Considering that the core is fairly stable now, and that important functions like what you describe are still missing, I think it's a really good time to get involved. -Bertrand Very interested in working on this (doing this outside normal work hours as a side project, though using sling within work for more general site development). Cheers Bryce
Re: Image rendering (image creation / manipulation)
Hi, On Thu, Jul 10, 2008 at 7:38 AM, Bryce Ewing <[EMAIL PROTECTED]> wrote: > ...After having a bit of time to think about this I think your suggestion to > have a java component to do this would be a good idea, and if then there is > a specific image scripting language built around that then so be it Sounds good! > ...Have spent a bit of time over the past few days looking into and trying to > integrate JAI and ImageIO into a bundle built by maven etc. etc. (and half > the time spent beating my head against a wall). I am not sure how well > using these libraries will work due to having to download them from Sun's > site rather than automatically getting them from a maven repository Is that because of their licenses that they cannot be put in a Maven repository? If you can point me to the exact libraries that you'd like to use, I can have a look. -Bertrand
Re: Image rendering (image creation / manipulation)
In trying to find the right links for you I found things that I hadn't before. Previously I was looking at: http://java.sun.com/products/java-media/jai/downloads/download-1_1_2_01.html Which is where you are pointed to if you try to get JAI from maven: http://mvnrepository.com/artifact/javax.media/jai_core Though that seems a bad option The libraries that I have had experience using are: JAI: https://jai.dev.java.net/ And ImageIO: https://jai-imageio.dev.java.net/ Both of these have native accelerated code versions (but also have in the case of JAI a pure java version, and for ImageIO it doesn't require the native code). I am not sure what the licenses are like in regards to use in the project, very interested in your input on that? I also noted when searching for alternatives: http://incubator.apache.org/sanselan/site/index.html Which looks interesting (though I have spent all of about 20 mins looking at it). I do notice however that Carsten is set as lead on this project in jira so maybe he might know something more about it? Maybe even pluggable? Cheers Bryce Bertrand Delacretaz wrote: Hi, On Thu, Jul 10, 2008 at 7:38 AM, Bryce Ewing <[EMAIL PROTECTED]> wrote: ...After having a bit of time to think about this I think your suggestion to have a java component to do this would be a good idea, and if then there is a specific image scripting language built around that then so be it Sounds good! ...Have spent a bit of time over the past few days looking into and trying to integrate JAI and ImageIO into a bundle built by maven etc. etc. (and half the time spent beating my head against a wall). I am not sure how well using these libraries will work due to having to download them from Sun's site rather than automatically getting them from a maven repository Is that because of their licenses that they cannot be put in a Maven repository? If you can point me to the exact libraries that you'd like to use, I can have a look. -Bertrand
Re: Image rendering (image creation / manipulation)
Bryce Ewing wrote: I also noted when searching for alternatives: http://incubator.apache.org/sanselan/site/index.html Which looks interesting (though I have spent all of about 20 mins looking at it). I do notice however that Carsten is set as lead on this project in jira so maybe he might know something more about it? Sanselan is a very nice project which allows you to read some images and their meta data and to write a few formats. Its a pure java lib. Maybe even pluggable? Internally it's pluggable, but there's currently no way to add own plugins. But :) we're desperately looking for new ideas, improvements etc. So you - and everyone else for course - is welcome to join the project. Thanks Carsten -- Carsten Ziegeler [EMAIL PROTECTED]
Re: Image rendering (image creation / manipulation)
After checking out the code and having more of a look at this library I have a better understanding of what it is. This is a replacement of the ImageIO library from sun, but the JAI library would still be required for image manipulation. What are the thoughts around using this library as part of built in support into sling for image manipulation? The issue I see would be that since this library is still in incubation that this would mean the sling image bundle wouldn't be able to be released until this project also comes out of incubation (correct me if I am wrong on this point) I also see that as a benefit for the Sanselan project as it would help "push" it along. Assuming there are no licensing issues with the JAI library (Bertrand have you had a chance to look at this?) I will start to put together a sling image bundle based around JAI and Sanselan. Cheers Bryce P.S. Carsten given I will be using Sanselan in this bundle I will have to get involved in the project ;) Carsten Ziegeler wrote: Bryce Ewing wrote: I also noted when searching for alternatives: http://incubator.apache.org/sanselan/site/index.html Which looks interesting (though I have spent all of about 20 mins looking at it). I do notice however that Carsten is set as lead on this project in jira so maybe he might know something more about it? Sanselan is a very nice project which allows you to read some images and their meta data and to write a few formats. Its a pure java lib. Maybe even pluggable? Internally it's pluggable, but there's currently no way to add own plugins. But :) we're desperately looking for new ideas, improvements etc. So you - and everyone else for course - is welcome to join the project. Thanks Carsten
Re: Image rendering (image creation / manipulation)
Hi, On Fri, Jul 11, 2008 at 3:43 PM, Bryce Ewing <[EMAIL PROTECTED]> wrote: > ...Assuming there are no licensing issues with the JAI library (Bertrand have > you had a chance to look at this?) I will start to put together a sling > image bundle based around JAI and Sanselan Can you confirm that in this case you'll need only the jai-core library? If yes I can try to find out if we're allowed to use it, as it uses a specific license (JDL) that's not currently mentioned at [1]. -Bertrand [1] http://www.apache.org/legal/resolved.html
Re: Image rendering (image creation / manipulation)
Hi Bertrand, Yes, just the jai-core libraries are required (there are two included in the releas of jai-core, jai-core jar and jai-codec jar - both covered by the same license). Hopeful to have something to show in this area sometime early next week. Cheers Bryce Bertrand Delacretaz wrote: Hi, On Fri, Jul 11, 2008 at 3:43 PM, Bryce Ewing <[EMAIL PROTECTED]> wrote: ...Assuming there are no licensing issues with the JAI library (Bertrand have you had a chance to look at this?) I will start to put together a sling image bundle based around JAI and Sanselan Can you confirm that in this case you'll need only the jai-core library? If yes I can try to find out if we're allowed to use it, as it uses a specific license (JDL) that's not currently mentioned at [1]. -Bertrand [1] http://www.apache.org/legal/resolved.html
Re: Image rendering (image creation / manipulation)
Hi Bryce, On Thu, Jul 17, 2008 at 8:30 AM, Bryce Ewing <[EMAIL PROTECTED]> wrote: > ...Yes, just the jai-core libraries are required (there are two included in > the > releas of jai-core, jai-core jar and jai-codec jar - both covered by the > same license) If you want to use jai-core, [3] indicates that we cannot put stuff that's under this "JAVA ADVANCED IMAGING DISTRIBUTION LICENSE (VER. 1.1.X)" [4] in a Maven repository, as (IIUC) the license specifies that the recipient must explicitely accept the JDL license. This means that if your code uses jai-core, we'd have to instruct users to download the libraries manually and add them to their Maven repository themselves. As an alternative, it seems like Apache Batik includes some or all of that stuff, could you have a look at [1] and see if that would be useful? According to [2] those libraries have been donated to Batik some time ago, so that might not be the latest stuff, what do you think? -Bertrand [1] http://svn.apache.org/repos/asf/xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/image/ [2] http://markmail.org/message/m66kvpjppq26kmuj [3] http://markmail.org/message/tl3nw4mcixpaxld4 [4] https://jai.dev.java.net/jdl-jai.pdf