cancel
Showing results for 
Search instead for 
Did you mean: 

Image transformation fails [see details]

esideveloper
Champ in-the-making
Champ in-the-making
Hello,

I have been trying to enable image transformation using ImageMagick in Alfresco to work, but failed thus far.

I made sure that I had ImageMagick is included in my Alfresco instance, and went through it's set up and some debugging suggestion, but I can only upload and image of size 0 bytes with transformation on it failing. I'm invoking the transformation via a web script javascript. I see the following in my log: any ideas?


2012-08-14 16:48:45,117  ERROR [repo.action.AsynchronousActionExecutionQueueImpl] [defaultAsyncAction3] Failed to execute asynchronous action: Action[ id=b7ec157c-2efb-4207-a466-603014092f49, node=null ]
org.alfresco.error.AlfrescoRuntimeException: 07140032 Creation of thumbnail 'doclib' failed
   at org.alfresco.repo.thumbnail.CreateThumbnailActionExecuter.executeImpl(CreateThumbnailActionExecuter.java:186)
   at org.alfresco.repo.action.executer.ActionExecuterAbstractBase.execute(ActionExecuterAbstractBase.java:196)
   at org.alfresco.repo.action.ActionServiceImpl.directActionExecution(ActionServiceImpl.java:780)
   at org.alfresco.repo.action.ActionServiceImpl.executeActionImpl(ActionServiceImpl.java:700)
   at org.alfresco.repo.action.AsynchronousActionExecutionQueueImpl$ActionExecutionWrapper$1$1.execute(AsynchronousActionExecutionQueueImpl.java:403)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:388)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:259)
   at org.alfresco.repo.action.AsynchronousActionExecutionQueueImpl$ActionExecutionWrapper$1.doWork(AsynchronousActionExecutionQueueImpl.java:412)
   at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:519)
   at org.alfresco.repo.action.AsynchronousActionExecutionQueueImpl$ActionExecutionWrapper.run(AsynchronousActionExecutionQueueImpl.java:415)
   at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
   at java.lang.Thread.run(Thread.java:662)
Caused by: org.alfresco.service.cmr.thumbnail.ThumbnailException: 07140031 07140030 Cannot find Content Reader for document. Operation can't be performed
   at org.alfresco.repo.thumbnail.ThumbnailServiceImpl.createThumbnailNode(ThumbnailServiceImpl.java:594)
   at org.alfresco.repo.thumbnail.ThumbnailServiceImpl.access$000(ThumbnailServiceImpl.java:67)
   at org.alfresco.repo.thumbnail.ThumbnailServiceImpl$1.doWork(ThumbnailServiceImpl.java:262)
   at org.alfresco.repo.thumbnail.ThumbnailServiceImpl$1.doWork(ThumbnailServiceImpl.java:259)
   at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:519)
   at org.alfresco.repo.thumbnail.ThumbnailServiceImpl.createThumbnail(ThumbnailServiceImpl.java:258)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
   at org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(AlwaysProceedMethodInterceptor.java:34)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:46)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:147)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
   at $Proxy123.createThumbnail(Unknown Source)
   at org.alfresco.repo.thumbnail.CreateThumbnailActionExecuter.executeImpl(CreateThumbnailActionExecuter.java:177)
   … 12 more
Caused by: org.alfresco.service.cmr.rendition.RenditionServiceException: 07140030 Cannot find Content Reader for document. Operation can't be performed
   at org.alfresco.repo.rendition.executer.AbstractRenderingEngine$RenderingContext.makeContentReader(AbstractRenderingEngine.java:822)
   at org.alfresco.repo.rendition.executer.AbstractTransformationRenderingEngine.render(AbstractTransformationRenderingEngine.java:88)
   at org.alfresco.repo.rendition.executer.AbstractRenderingEngine.executeRenditionImpl(AbstractRenderingEngine.java:504)
   at org.alfresco.repo.rendition.executer.AbstractRenderingEngine$1.doWork(AbstractRenderingEngine.java:428)
   at org.alfresco.repo.rendition.executer.AbstractRenderingEngine$1.doWork(AbstractRenderingEngine.java:408)
   at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:519)
   at org.alfresco.repo.rendition.executer.AbstractRenderingEngine.executeImpl(AbstractRenderingEngine.java:407)
   at org.alfresco.repo.rendition.executer.AbstractRenderingEngine.executeImpl(AbstractRenderingEngine.java:369)
   at org.alfresco.repo.action.executer.ActionExecuterAbstractBase.execute(ActionExecuterAbstractBase.java:196)
   at org.alfresco.repo.action.ActionServiceImpl.directActionExecution(ActionServiceImpl.java:780)
   at org.alfresco.repo.action.ActionServiceImpl.executeActionImpl(ActionServiceImpl.java:700)
   at org.alfresco.repo.action.ActionServiceImpl.executeAction(ActionServiceImpl.java:538)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
   at org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(AlwaysProceedMethodInterceptor.java:34)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:46)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:147)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
   at $Proxy37.executeAction(Unknown Source)
   at org.alfresco.repo.rendition.RenditionServiceImpl.executeRenditionAction(RenditionServiceImpl.java:281)
   at org.alfresco.repo.rendition.RenditionServiceImpl.render(RenditionServiceImpl.java:183)
   at org.alfresco.repo.thumbnail.ThumbnailServiceImpl.createThumbnailNode(ThumbnailServiceImpl.java:588)
   … 35 more
4 REPLIES 4

marco_altieri
Star Contributor
Star Contributor
Hi,

I think that you should post the webscript that you are using to create the documents otherwise it's difficult to understand the problem.

Anyway, it seems a problem with the content of the node. Are you sure that the node has been created correctly? Can you download its content?
Are you sure that, when you invoke the transformation,the content of the node is already available?

Regards,
Marco

esideveloper
Champ in-the-making
Champ in-the-making
Thanks for your quick response, the web script is below, I use it to upload a user's profile picture.

// arguments
var userId = args.userId;
var height = 160;
var width = 160;
var imageName = 'ProfileImage.jpeg';
var imagePath = 'User Homes/Site/' + userId + '/uploads';
var imageTitle = 'User profile picture for user ' + userId;
var imageDescription = 'User profile picture for user ' + userId;
var tempPath = imagePath + '/temp';
var tempImageName = 'tmp_' + imageName;
var image = null;

// get image file from form
for each(field in formdata.fields) {
    if (field.name == 'file' && field.isFile) {
        image = field;
    }
}

// ensure file has been uploaded
if (image == null) {
    throwError(400, 'Upload file not provided');
}
else if (image.filename == '') {
    throwError(500, 'Uploaded file cannot be located');
}
else {

    // delete temporary folder, if it exists (in order to remove all its existing content)
    var tempPathNode = companyhome.childByNamePath(tempPath);
   
    if (tempPathNode != null) {
        var removed = tempPathNode.remove();
      
      // if temporary folder removal fails, throw exception
      if (!removed) {
            throwError(500, 'Removing temporary folder: ' + tempPath + ' failed for user: ' + userId);
        }
    }

   // re-create temporary folder, to use in this upload operation
    tempPathNode = companyhome.createFolder(tempPath);
   
   // if temporary folder creation fails, throw exception
   if (tempPathNode == null) {
      throwError(500, 'Creating temporary folder: ' + tempPath + ' failed for user: ' + userId);
   }
   
   var imagePathNode = companyhome.childByNamePath(imagePath);
   
   // if image upload folder does not exist, throw exception
   if (imagePathNode == null) {
      throwError(500, 'Cannot find image uploads folder: ' + imagePath + ' for user: ' + userId);
   }
   
    var oldImage = imagePathNode.childByNamePath(imageName);

    // if an old image already exists, move it to temporary folder above
    if (oldImage != null) {
        moveImage(oldImage, tempPathNode);
    }

    // upload new image to temporary folder
    upload = tempPathNode.createFile(tempImageName);
    upload.properties.content.guessMimetype(image.filename);
    upload.properties.content.write(image.content);
    upload.properties.title = imageTitle;
    upload.properties.description = imageDescription;
    upload.save();

    // determine image dimensions
    var imageDimensions = imageDimensions(upload, height, width);

    // if determining image dimensions fails, return old image from temporary folder to original location, and throw exception
    if (imageDimensions == null) {
        if (oldImage != null) {
         moveImage(oldImage, imagePathNode);
      }
      
        throwError(500, 'Determining image dimensions failed for user: ' + userId);
    }

    // rename image before saving it on transformation
   upload.properties.name = imageName;
    var transformedImage = upload.transformImage('image/jpeg', imageDimensions, imagePathNode);

    // if image transformation fails, return old file from temporary folder to original location, and throw exception
    if (transformedImage == null) {
        if (oldImage != null) {
         moveImage(oldImage, imagePathNode);
      }
      
        throwError(500, 'File transformation failed for user: ' + userId);
    }

    // remove the temporary folder
    tempPathNode.remove();

    //setup model for response template      
    model.upload = upload;
}

function throwError(errorCode, message) {
    status.code = errorCode;
    status.message = message;
    status.redirect = true;
}

function imageDimensions(image, height, width) {
    var dimensions = null;
    var imageHeight = image.properties.height;
    var imageWidth = image.properties.width;

    if (imageHeight >= imageWidth) {
        // set to fixed height. keep aspect ratio
        dimensions = '-resize x' + height;
    } else {
        // set to fixed width. keep aspect ratio
        dimensions = '-resize ' + width;
    }

    return dimensions;
}

function moveImage(image, pathNode) {
    var moved = image.move(pathNode);
   
   // if move fails, throw an an error
   if (!moved) {
        throwError(500, 'Moving image file to location: ' + pathNode + ' failed for user: ' + userId);
    }
}

esideveloper
Champ in-the-making
Champ in-the-making
Yes, the node does exist. I can upload the file with the web script if I call the web script directly through Alfresco (as in /alfresco/services/myuploadscript). But this fails when I set the action on the form to be submitted to post to a page that calls the web script. I'm new to Alfresco, but I hopefully this makes sense

esideveloper
Champ in-the-making
Champ in-the-making
Sorry, I'm posting message to the wrong post, my issue with image transformation had been resolved, I just had to make sure that the generated transformed image was created in a separate folder, and not in the same folder as the original image (see web script above)