cancel
Showing results for 
Search instead for 
Did you mean: 

Create a new TIFF node automatically

jlabuelo
Champ on-the-rise
Champ on-the-rise
Good morning all

We are creating a wizard that would produce a new "jpg" node and we will add to it some image content. To do this we apply this code:

properties.put(ContentModel.PROP_CONTENT, new ContentData(null, MimetypeMap.MIMETYPE_IMAGE_JPEG, 0L, null));

However we would need to produce a node of type "TIFF" instead of "jpg" but we can not use the
MimetypeMap.MIMETYPE_IMAGE_TIFF
as it does not exists

Does anyone know a way to produce a new TIFF node as a result of a wizard… maybe transforming the jpg node produced to TIFF…but how?

Thanks a lot for your ideas in advance!
2 REPLIES 2

mikeh
Star Contributor
Star Contributor
It's not a complete solution, but the second parameter of the ContentData() constructor is just a string, so you can pass in "image/tiff" directly.

Thanks,
Mike

jlabuelo
Champ on-the-rise
Champ on-the-rise
Hi Mike

Thanks a lot for the answer. After making those changes I am able to produce a new TIFF node, however when I try to add the image conent to the node it fails. I mean I can see a node_name.tif in the repository of alfresco, but the content is empty.

I think it is in this section:
 File outputfile = File.createTempFile("file", "aux");
                    outputfile.createNewFile();
                    ImageIO.write(Image_Content, "tiff", outputfile);
                   
                    ContentWriter writer2 = getContentService().getWriter(this.newNodeRecorte.getNodeRef(), ContentModel.PROP_CONTENT, true);
                    // set the mimetype and encoding
                   
                    writer2.setMimetype("image/tiff");
                    writer2.setEncoding("UTF-8");
                
                       writer2.putContent(outputfile);
                   // Destruimolo ficheiro final
                       outputfile.delete();

I am not sure if the function ImageIO.write allow us to introduce the "tiff" parameter or it is restricted to "jpg", "png","GIF". Do you know a better idea to transform a java.awt.Image in an Alfresco TIFF node?

Cheers