Re: IMAGEOP Block

2014-09-18 Thread Peter Sparkes

Hi David,

Thanks for investigating it.

I am using java 6 on a linux box.

Unfortunately my java is not up to debugging it.

Would it work if I replaced the 2.1 jar with the 2.2 one

Regards

Peter


On 18/09/2014 02:08, David Crossley wrote:

On Wed, Sep 17, 2014 at 11:31:20AM +0100, Peter Sparkes wrote:

Hi

Cocoon 2.1.12

I can't get scale and resize function in the imageop block to work on
cocoon 2.1.12.

I have the following working

  * Display image with original size and colour
  * Tint image various colour


Miguel has been kindly helping me, but he uses cocoon 2.2. Miguel has it
working on 2.2, see below.

Is there a difference between your versions of Java?


Please, has anyone got imageop scale and resize working on 2.1.12?

No. I looked yesterday at Cocoon running locally using the SVN branch
2.1.13-dev
The block samples show the same as what you described above.
The cocoon log file does show the errors, but doesn't mean much to me.
This was with Java 8.

The only thing that i can suggest is to look at the changes that
have been made to the code in 2.2 and compare with 2.1 branch.

http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/
http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-imageop/

Perhaps when the last changes were made, then there was a slight
difference, and perhaps no-one tested after that.

Those last changes seem to be
https://issues.apache.org/jira/browse/COCOON-2169
https://issues.apache.org/jira/browse/COCOON-2177

-David


Thanks

Peter



On 17/09/2014 07:11, Miguel wrote:

I've done some test and modulo in cocoon 2.2 project works fine. I
describe step by step:

a) Include dependency into pom file of my project:

dependency
  groupIdorg.apache.cocoon/groupId
  artifactIdcocoon-imageop-impl/artifactId
  version1.0.0-SNAPSHOT/version
/dependency

b) Include test map:match into sitemap.xmap:

map:match pattern=prueba/*/scale-*-*
map:read type=image-op-scale
src=themer/themes/common/images/{1}
  map:parameter name=scale-scale value={2} /
  map:parameter name=output-format value={3} /
/map:read
  /map:match

  map:match pattern=prueba/*/resize-*-*
map:read type=image-op-resize
src=themer/themes/common/images/{1}
  map:parameter name=size-width value={2} /
  map:parameter name=size-height value={3} /
/map:read
  /map:match

themer/themes/common/images/ is the route to my images's folder

c) start my project and I test:

* http://localhost:8080/prueba/audio.gif/scale-2.5-jpg
* http://localhost:8080/prueba/audio.gif/resize-100-50

All works fine.


El 16/09/2014 22:27, Peter Sparkes escribió:

Hi Miguel,

My java is not good enough debug the block imageop to see what
parameters's value arrive to class

However as

  * Display image with original size and colour
  * Tint image various colour

are working I assume there is access to image.

http://cocoon.zones.apache.org/cocoon22/cocoon-imageop-sample/ also gives
errors on resize (scalling)

Peter



On 16/09/2014 13:52, Miguel wrote:

Hi Peter

  It seems that there isn't access to image or similar error to read it.
I advise you debug the block imageop to see what parameters's value
arrive to class.


This block has only three bugs, and all are fixed, so I think module
must works.
https://issues.apache.org/jira/browse/COCOON/component/12311751/?selectedTab=com.atlassian.jira.jira-projects-plugin:component-summary-panel



El 16/09/2014 14:03, Peter Sparkes escribió:

I am using the Samples block on cocoon 2.1.12

...//samples/blocks/imageop/logo2.png/resize-50-50 gives the following
error:

java.awt.image.ImagingOpException: Unable to transform src image

Cocoon stacktrace[hide]

*Failed to process reader*
context://samples/blocks/imageop/sitemap.xmap - 46:53   /map:read
type=image-op-resize/
context://samples/blocks/sitemap.xmap - 67:68   /map:mount/
context://samples/sitemap.xmap - 198:66 /map:mount/
context://sitemap.xmap - 1086:92/map:mount/


Java stacktrace[hide]

java.awt.image.ImagingOpException: Unable to transform src image
at
java.awt.image.AffineTransformOp.filter(AffineTransformOp.java:357)
at

org.apache.cocoon.reading.imageop.ResizeOperation.apply(ResizeOperation.java:96)
at

org.apache.cocoon.reading.imageop.ImageOpReader.applyEffectsStack(ImageOpReader.java:193)
at

org.apache.cocoon.reading.imageop.ImageOpReader.processStream(ImageOpReader.java:123)
at

org.apache.cocoon.reading.ResourceReader.generate(ResourceReader.java:332)



On 16/09/2014 12:36, Miguel wrote:

Have you checked dependencies?
Have you tried to use block: cocoon-imageop-sample?
Can you show error message when you use transformer?


El 16/09/2014 13:14, Peter Sparkes escribió:

Hi Miguel,

I have implemented imageop, however, the only samples that work are:

  * Display image with original size and colour
  * Tint 

Resizing images using imgscalr

2014-09-18 Thread Peter Sparkes

Hi,

Cocoon 2.1.12

 I use the following javascript ( Text in Black )with the Cocoon Upload widget uploading images 
to the upload-dir and then move them to the lodgeimage300px directory. This works


I now want to scale the images using imgscalr , 
http://www.thebuzzmedia.com/software/imgscalr-java-image-scaling-library/#source


I, therefore, added the code in red

The BufferedImage   in BufferedImage scaledImage =Scalr.resize(file, 200); gave 
me a syntax error.

On removing BufferedImage   I get the following error Scalr is not defined

Can anyone help me Please

Peter

importClass(Packages.java.io.File);
importClass(Packages.java.io.FileOutputStream);
importClass(Packages.java.io.FileNotFoundException);

importClass(org.imgscalr.Scalr);
importClass(Packages.java.awt.image.BufferedImage);
importClass(Packages.javax.imageio.ImageIO);

function uploadprogress() {

var form = new Form(forms/uploadprogress_model.xml);
form.setAttribute(counter, new java.lang.Integer(0));
var k = form.showForm(uploadprogress-display-pipeline.jx);

//var fileSource = D:/cocoon-2.1.11-wl/build/webapp/upload-dir/; //for 
testing
var fileSource = 
/usr/share/tomcat7/instances/chinese-dev/webapps/ROOT/upload-dir/;

//var fileTarget = 
D:/cocoon-2.1.11-wl/build/webapp/resources/imagesSmall/; //for testing
var fileTarget = 
/usr/share/tomcat7/instances/chinese-dev/webapps/ROOT/resources/lodgeimages300px/;



var fileSourcePath = ;
var fileTargetPath = ;
var file = ;

var resizedTargetPath = 
/usr/local/tomcat/instances/chinese-dev/webapps/ROOT/resources/lodgeimagesSmall/;

var resizedfileTargetPath = resizedTargetPath+test.jpg;
var scaledImage = ;

k.invalidate(); // do not allow return to the form

var files = [];
var repeater = form.getChild(uploads);
for (var i = 0; i  repeater.getSize(); i++) {
var upload = repeater.getRow(i).getChild(upload);
files[i] = {
filename: upload.value.fileName,
bytes: upload.value.size
};
   fileSourcePath = fileSource + upload.value.fileName;
   fileTargetPath = fileTarget + upload.value.fileName;
   file = new File(fileSourcePath);
   file.renameTo(new File(fileTargetPath));

  BufferedImage scaledImage =Scalr.resize(file, 200);



}
cocoon.sendPage(upload-images-success.jx,
{
files: files
}
);
}



I now want to extend uploadprogress() to scale the images before moving them to their target 
directory using


  imgscalr, 
http://www.thebuzzmedia.com/software/imgscalr-java-image-scaling-library/#source