Writing IIOImage as TIFF

When I read an IIOImage from a TIFF file, and then turn around and write that IIOImage back to a different TIFF file, the resultant file is chewed up (the image looks like it has had a bad hair day).
If I create a new IIOImage based on the one I read, then write that to a new TIFF file, it works like a champ.
When I write the original IIOImage to other formats (GIF, PNG, JPEG), they come across perfectly.
Can anyone explain what might be causing this? The code snippet below should create the problem (uncomment the TEST CASE 1 or TEST CASE 2 line).
Thanks much,
- K
public void test(){
     ImageReader reader = (ImageReader)ImageIO.getImageReadersByFormatName("tif").next();
     System.out.println("Found reader " + reader);
     ImageInputStream iis = new FileImageInputStream(file);
     reader.setInput(iis);
     IIOImage iimage = reader.readAll(0, new ImageReadParam());
     String outputFilename = name + "2.tif";
     File outputFile = new File(outputFilename);
     ImageWriter writer = (ImageWriter)ImageIO.getImageWritersByFormatName(selection).next();
     System.out.println("Found writer " + writer);
     ImageOutputStream ios = new FileImageOutputStream(outputFile);
     writer.setOutput(ios);
// TEST CASE 1:  this creates a junk TIFF
//      writer.write(image);
// TEST CASE 2: this creates a nice looking TIFF
//     writer.write(new IIOImage(image, null, null));     
     ios.close();
}

ImageWriter writer = (ImageWriter)ImageIO.getImageWritersByFormatName(selection).next();
System.out.println("Found writer " + writer);Perhaps Because: You are choosing the First Writer available that claims to be
able to encode ".tif"
Now I'm not very cluey on this, but from my 'work' with imageIO
it seems that the Iterator of readers / writers does not always come back the same way,
By Luck I've been getting an OK TIF writer the first time,
But for the readers I'm not so lucky.
I 'loop' over the Iterator of Writers, til I get one that didn't come back with some sort of complaint.
OR Exception not mentioned in the docs!
If someone could help by showing how to choose the "correct" reader / writer , perhaps using the IIOMetadata , it would be great!
As to WHy TEST CASE 1 and TEST CASE 2 Are different
I would assume that by instantiating a new IIOImage()
with no Thumbnails and null Metadata:
The returned IIOImage is in a format that JAVA ImageIO "Likes Better"
Your Original Image may have Metadata in it ? {I'm not sure if that comes in for free or not } and that Metadata is from your code
Unset, In TEST CASE 2 you specifically set it to null.
Whereas TEST CASE 1 does this:
public void write(IIOImage image)throws IOException
     Appends a complete image stream containing a single image with default metadata and thumbnails to the output. This method is a shorthand for
     write(null, image, null). I'd guess the First Writer out of the Iterator behaves better with the supplied data.
Interpreting Metadata ?

Similar Messages

  • Work around for writing out metadata to masters?

    I am sure that the aperture community has dealt with this before.
    Prior to purchasing aperture, I made sure that metadata like captions keywords, etc. could be written back out to the master file. This would allow one to not be held hostage to aperture. With various updates this ability has gone away. The statement from Apple less than a year ago, seems to indicate that aperture will not write metadata back out to the Masters.
    Quote: http://support.apple.com/kb/TA23784?viewlocale=en_US
    By Design: Aperture won't export metadata with RAW masters
    Unlike applications such as Photo Mechanic, Aperture does not write IPTC and keywords to the original RAW file. Instead, Aperture stores this information in its library and attaches it when exporting versions in JPEG, TIFF, PSD, or PNG format. If you export the RAW masters, none of your metadata changes will come along with them. Unlike the issues listed above, this feature is by design.
    If your goal is to archive RAW files outside of Aperture with metadata attached, you'll need a workaround to this aspect of Aperture's metadata handling. Because Aperture is designed to read added metadata at time of import (despite the current issue described above), the best long term solution (after issues are resolved) will be to add your metadata in Photo Mechanic (or similar) prior to importing them to Aperture and then refrain for the most part from using Aperture's metadata tools. If you don't like that workaround, a secondary workaround is to export JPEG versions to be kept alongside the RAW masters. To save disk space, the JPEG copies could be a minimal size."
    I am sure that many community members have encountered this problem. Specifically, I have many slides to scan, so the raw input file is a tiff. Aperture does not support writing metadata to tiffs. And to depend on aperture to write out metadata to any master file is probably setting yourself up for disappointment.
    Can the community recommend a way around this?
    Thanks

    You are referring to a very old document about Aperture 1, clearly marked as 'no longer updated'. Aperture 3 can export IPTC metadata with RAW files. You have the choice of embedding them into the RAW file, or write them in a separate xmp sidecar file. Just choose 'Export Master'. Aperture can also write back metadata into a RAW file without exporting them. Choose 'Metatadata - Write IPTC metadata to original'.

  • Print images created on the fly by a servlet

    Please, look at it... my tiff image doesn't print in my browser (IE6).
    Could somone tell me why !????
    // Method of a "Page" class
    public void write (OutputStream out) {
                // Reading of the tiff file (this.tempFile is a valid File)
         PlanarImage image    = JAI.create("fileload", this.tempFile.getCanonicalPath ());
                /*   // Test : the writed file is a valid tiff file --> the reading is OK !
                 *   File outFile = new File ("c:\\temp\\JLdsWeb\\Test.tif");
                 *   RenderedOp op = JAI.create("filestore", image, outFile.getCanonicalPath (), "tiff");
         // Writing of the tiff file in the received OutputStream
                JAI.create("encode", image, out, this.FORMAT_NAME, null);
    // my 1st JSP :page.jsp (to call the 2nd JSP witch have an other content type)
    <%@page
    contentType="text/html"
    language="java"
    errorPage="errorpage.jsp"
    import="com.damaris.ldsweb.*,com.damaris.data.*,com.damaris.page.*,java.util.*"
    %>
    <html>
    <head></head>
    <body>
    <IMG src=<%=request.getContextPath()%>image.jsp>
    </body>
    </html>
    // my 2nd JSP
    <%@page
    language="java"
    errorPage="errorpage.jsp"
    import="com.damaris.ldsweb.*,com.damaris.data.*,com.damaris.page.*,java.util.*"
    %>
    <html>
    <head>
    <%
        // pageToPrint is an instance of the class "Page" (getContentType ( ) give the String "image/tiff")
        response.setContentType(pageToPrint.getContentType ( ));
    %>
    </head>
    <body>
    <%
        ServletOutputStream bOut = response.getOutputStream();
        pageToPrint.write (bOut);
    %>
    </body>
    </html>

    You can get the Servlet to write an image out by changing the content type of the response object to "image/jpeg" and write the bytes of the image out down a ServletOutputStream you create from the response object.
    You must change the content type before you write anything to the response object. The servlet can only produce the image.
    I did it once but I've lost my code and am now trying to recreate it (I changed it to having a server app do the image processing and writing it to a socket which the servlet read the bytes from and wrote them to the ServletOutputStream but now want the servlet to do the processing).

  • Writing XMP to multiple file formats (PDF, JPEG,  TIFF, etc)

    Hi,
    I am developing a server-side component that embeds XMP data into a file (of various formats) and then provides these files for client download.
    I have been using the XMP toolkit for generating the metadata, however i now have the problem of getting this metadata into the relevant file. I could always develop this myself but it seems like a huge amount of work. So to make my life easier, does anyone know of any toolkits (from adobe or otherwise) that support writing XMP data into different file formats (PDF, JPEG, TIFF, AIFF, MPEG etc) ??
    I am developing in Java so I would prefer Java libraries, however I can always use JNI calls to C/C++ (as i have with the XMP toolkit).
    Any help would be very appreciated.
    Regards,
    Jude

    Greetings,
    I think we should standardize some information, I know for a fack, that I will support adding XMP metadata in the HDF, RIFF, IFF and OLE file formats. If you have any specific suggestions on the chunk information or signature information that I should use, let me know?
    For my part, I was thinking of adding RIFF,IFF chunks with the name \ xmp in those file formats. For OLE, maybe an added stream with the xmp name (in UTF-16).
    Comments welcome everyone!

  • Can I automate the writing of XMP metadata into JPEG and TIFF files?

    I have written an ASP.NET 3.5 website application on behalf of an annual international photographic competition. Entrants will be uploading digital photos in either JPEG or TIFF format. Ideally, I would write entrant identity and image title information into the XMP metadata for each image immediately after upload - but so far, I have failed to find any way to do this in ASP.NET.
    Thousands of images are involved, so I need to find a way to automate the metadata insertion, perhaps with some sort of script that uses a text file (extracted from the SQL Server database on my website) as the source of the metadata for a batch of images. Is this the sort of task that can be done by writing a script for Bridge CS3? Are there any scripts already in existence that I could use? I am a total beginner in this area.
    I use a Win XP PC, though I have a colleague who, I think, has CS3 on his Mac (running under the Leopard OS), so scripts for either platform might be usable.
    David

    You are the man X!
    Ok here is another version with a check for the dll.
    #target bridge 
       if( BridgeTalk.appName == "bridge" ) {
    addInfo = new MenuElement("command", "Update Entry Details", "at the end of Thumbnail");
    addInfo .onSelect = function () {
         main();
    function main(){
    var csv = File.openDialog("Please select CSV file.","CSV File:*.csv");
    if(csv != null){
    loadXMPScript();
    csv.open("r");
    while(!csv.eof){ 
       strInputLine = csv.readln();
       if (strInputLine.length > 3) {
          strInputLine = strInputLine.replace(/\\/g,'/');
       inputArray  = strInputLine.split(",");
       var csvFile = new File(inputArray[0]);
       var title = inputArray[1];
       var author = inputArray[2];
    if(!csvFile.exists) {
    alert(csvFile + " Does not exist"); //////////Check if file exists
    return;
    if(csvFile.exists){
    var file = new Thumbnail(csvFile);
    try{
    var xmpFile = new XMPFile(file.path, XMPConst.UNKNOWN,XMPConst.OPEN_FOR_UPDATE);
    }catch(e){
          alert("Problem opening xmp for update:-\r" + file.path +"\r" +e.message);
          return;
    try{
    var xmp = xmpFile.getXMP();
    }catch(e){
          alert("Problem opening xmp data:-\r"  + e.message);
          return;
    xmp.deleteProperty(XMPConst.NS_DC, "creator");
    xmp.deleteProperty(XMPConst.NS_DC, "title");
    try{
    xmp.appendArrayItem(XMPConst.NS_DC, "creator", author, 0,XMPConst.ARRAY_IS_ORDERED);
    xmp.appendArrayItem(XMPConst.NS_DC, "title", title, 0,XMPConst.ARRAY_IS_ORDERED);
    }catch(e){
          alert("Problem writing xmp data:-\r"  + e.message);
          return;
    if (xmpFile.canPutXMP(xmp)) {
    xmpFile.putXMP(xmp);
    }else{
    alert("Can not write new metadata to " + csvFile.spec); 
    xmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
    unloadXMPScript();
    function loadXMPScript()
       var results = new XMPLibMsg("XMPScript Library already loaded", 0, false);
       if (!ExternalObject.AdobeXMPScript)
          try
             ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');    
             results.message = "XMPScript Library loaded";
          catch (e)
             alert("Could not load AdobeXMPScript \r" + e.message);
             results.message = "ERROR Loading AdobeXMPScript: " + e;
             results.line = e.line;
             results.error = true;
       return results;
    function unloadXMPScript()
       var results = new XMPLibMsg("XMPScript Library not loaded", 0, false);
       if( ExternalObject.AdobeXMPScript )
          try
             ExternalObject.AdobeXMPScript.unload();
             ExternalObject.AdobeXMPScript = undefined;
             results.message = "XMPScript Library successfully unloaded";
          catch (e)
             results.message = "ERROR unloading AdobeXMPScript: " + e;
             results.line = e.line;
             results.error = true;
       return results;
    function XMPLibMsg (inMessage, inLine, inError)
       this.message = inMessage;
       this.line = inLine;
       this.error = inError;

  • TIFF-VIs for reading/writing from/to files

    To whom it may concern,
    I'm looking for TIFF-VIs for reading/writing from/to files
    for Labview 6 without any add-on package.
    Unfortunately I can't use TiffRd04 and TiffSv05 from
    Koji Ohashi due to the different file format!
    Any hints?
    Thank you in advance. Best regards from Germany
    Udo Weik

    Hi Udo,
    did you check these TIFF related libraries? .. maybe one of them is working.
    Good Luck

  • Reading TIFF, Writing JPEG with Advanced Imaging

    I am working on a servlet that will read a TIFF image file from a SOCKET connection, and write it to a JPEG file for viewing by the user. I've been able to read the TIFF file into a byte array, but I'm not sure how to write it back out as a JPEG. The code snippet below is being used to read the TIFF from the SOCKET:
    for (int i=0; i < imageCount; i++)
    imageSocket = new Socket("imageServer", 4178);
    toImage = new PrintWriter(imageSocket.getOutputStream(), true);
    fromImage = new BufferedReader(new InputStreamReader(imageSocket.getInputStream()));
    toImage.println(imageNames);
    int fileSize = Integer.parseInt(fromImage.readLine());
    if (fileSize > 0)
    byte[] image = new byte[fileSize];
    for (int j=0; j < fileSize; j++)
    image[j] = (byte) fromImage.read();                
    else
    System.out.println("file size is zero"); /* display msg for now */
    I'd prefer to do this using the Advanced Imaging API,s but can't find a decent example to look at. Can anyone help me find a better way of doing this?
    Thanks!

    You will get some help from following guide.
    http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/index.html

  • Reading 8kb tiff image and then writing into backend. please help

    Hi All, Please Help ..
    My aim is to read a tiff image which of 8kb 1732x717 size, and then store it into backend.
    what I did is read the image into bufferedImage and then used tiffencodeparam with compression_none but the problem is size is too much after encoding.
    code sample
    BufferedImage image = ImageIO.read(tiff_filename); to read tiff image
    to write tiff image
    TiffEncodeParam p = new TiffEncodeParam();
    p.setCompression(TiffEncdeParam.COMPRESSION_NONE);
    FileOutputStream out = new FIleOutputStream(tiff_filename);
    ImageEncoder e = ImageCodec.createImageEncoder(""TIFF,out,p);
    e.encode(image);
    out.close();

    I got all my pictures AND everything else back, folders, ratings, keywords etc
    Fortunately I had a backup of the entire iPhoto library folder, it was about 3 months old (I know shame on me) so I didn't want to just use the entire backup folder and lose 3 months of photos.
    So I just copied the AlbumData.xml file and the Library6.iPhoto file. PRESTO all my pictures were back WITH all the folders,keywords etc, etc intact!! (up till the 3 month old backup point).
    Then I just re-imported the missing 3 months worth of pictures from the original folder in the iphoto library folder. So all I had to recreate was 3 months worth of customization. WHEW!!
    Reading through the discussions it seems there is a fair number of users where iPhoto would go empty, but they knew the images were still on the computer. I am not a programmer, but it seems silly to me the their are files that get re-written everytime iPhoto closes....computers crash. and then what happens to the files? Mine got corrupted, lesson learned BACKUP more frequently!!
    Thanks to Old Toad who steered me to the Library6.iPhoto as a possible troublemaker in another thread!

  • Writing Adobe Image Resource Block to a Tiff file

    Background :
    I am working on a small .NET application which reads the tiff file and performs some metadata related operations on it.
    The program works fine with all of the tiff Images that are taken from photoshop. I have recieved a tiff file from the client which does not work with the program.
    I checked the metadata info for the file using imagemagik following is the output
      Format: TIFF (Tagged Image File Format)
      Mime type: image/tiff
      Class: DirectClass
      Geometry: 6986x3754+0+0
      Resolution: 96x96
      Print size: 72.7708x39.1042
      Units: PixelsPerInch
      Type: TrueColorAlpha
      Base type: TrueColor
      Endianess: MSB
      Colorspace: sRGB
      Depth: 8-bit
      Channel depth:
        red: 8-bit
        green: 8-bit
        blue: 8-bit
        alpha: 8-bit
      Channel statistics:
        Red:
          min: 37 (0.145098)
          max: 255 (1)
          mean: 215.041 (0.843299)
          standard deviation: 48.8483 (0.191562)
          kurtosis: 0.845012
          skewness: -1.09632
        Green:
          min: 25 (0.0980392)
          max: 255 (1)
          mean: 213.399 (0.836859)
          standard deviation: 50.853 (0.199424)
          kurtosis: 0.908226
          skewness: -1.09806
        Blue:
          min: 21 (0.0823529)
          max: 255 (1)
          mean: 210.495 (0.825471)
          standard deviation: 53.6527 (0.210403)
          kurtosis: 0.124965
          skewness: -0.929882
        Alpha:
          min: 64 (0.25098)
          max: 255 (1)
          mean: 254.948 (0.999796)
          standard deviation: 2.56957 (0.0100768)
          kurtosis: 2437.44
          skewness: 49.3893
      Image statistics:
        Overall:
          min: 0 (0)
          max: 255 (1)
          mean: 159.747 (0.626458)
          standard deviation: 44.321 (0.173808)
          kurtosis: 48.4205
          skewness: -8.00071
      Rendering intent: Perceptual
      Gamma: 0.454545
      Chromaticity:
        red primary: (0.64,0.33)
        green primary: (0.3,0.6)
        blue primary: (0.15,0.06)
        white point: (0.3127,0.329)
      Background color: white
      Border color: srgba(223,223,223,1)
      Matte color: grey74
      Transparent color: none
      Interlace: None
      Intensity: Undefined
      Compose: Over
      Page geometry: 6986x3754+0+0
      Dispose: Undefined
      Iterations: 0
      Compression: LZW
      Orientation: TopLeft
      Properties:
        date:create: 2014-02-15T21:18:37+06:00
        date:modify: 2014-02-09T16:29:10+06:00
        signature: a5c4a9415437ee2d3b0c3d860b30c5367f73fe7553c3f54923caf6da4b9e4623
        tiff:alpha: unassociated
        tiff:endian: lsb
        tiff:photometric: RGB
        tiff:rows-per-strip: 3754
      Artifacts:
        filename: C:\Users\Jane\TiffPathOperation\bin\Debug\Example1client_no_path.tiff
        verbose: true
      Tainted: False
      Filesize: 14.6MB
      Number pixels: 26.23M
      Pixels per second: 54.64MB
      User time: 0.484u
      Elapsed time: 0:01.479
      Version: ImageMagick 6.8.7-4 2013-10-26 Q16 http://www.imagemagick.org
    Unlike other tiff images this image does not contain 8bim profile information, which is required for proper execution of the program
    Profiles:
      Profile-8bim: 11720 bytes
      Profile-icc: 3144 bytes
        Description: sRGB IEC61966-2.1
        Manufacturer: IEC http://www.iec.ch
        Model: IEC 61966-2.1 Default RGB colour space - sRGB
        Copyright: Copyright (c) 1998 Hewlett-Packard Company
      Profile-xmp: 19368 bytes
    Possible solution :
    I would have to add the Image resource block data to such image in which the profile information is missing.
    Problem :
    I would have to write metadata for the tag 34377 as given in the Adobe Specification for the listed resource Id
    How am I suppose to write this entire block and assign it to the Tag 34377 in C#?
    What values should be added for each resource Id ?   
    Tiff Image : http://1drv.ms/NtzbCr

    Bypassing the portion of the file is not a option in my case since a part
    of the program reads the bytes and performs operation on the image when it
    reads 8bim.
    The image if re-saved in Photoshop gets the required metadata. (Can be seen
    by using imagemagik's identify utility)
    Only option that I have is to write the information for the resource in
    side the Image resource block tag.
    How am I suppose to write this resources when I am using BitmapMetadata
    class?
    Regards,
    Charanraj Golla

  • Image Reading Writing from TIFF format

    I have tiff files which contain average 30 images, i want to split it in batch. batch can be of 5 images or 10 images, it can be varry.
    Pls Help....
    Divyesh

    Java ImageIO can do this for you. You'll need to do a bit of reading about it, there is plenty to digest on this forum and in various parts of the internet.
    If you have any further, more specific questions, please ask.

  • Reading in data from IPTC keywords from a CSV and writing those keywords to TIFF images

    Hi All,
    I have a client that I'm working with that has a specific request for a script, or possibly a plugin.  I'm interested in both hearing if folks here think it is feasible, and also if anybody here would be interested in doing the work on this.
    I have never done PhotoShop scripting and I think it would be the best use of resources to subscontract this out, unless it proves exceedingly easy.  The kind of thing someone can do in a single forum post.  In which case, if you do that for me, I'll be sure to get you something for your time as a thank you :-)
    Here's the situation: my client runs a niche stock photography business and deals with tens of thousands of hi-res TIFF images.  Each of those images is assigned a list of keywords, a serial number, the photographer who took the picture, the date, the location, etc.  Lots of information.  He's got a FileMaker Pro database where he stores all that information.
    Some of those bits of information he also wants in the IPTC data for the TIFF image.  The keywords in particular are the main field he's interested in getting into the TIFF images.
    He has been dealing with this process manually so far in Bridge CS4.  He goes to each image, and copy/pastes the keywords into the IPTC data.  But he's interested in figuring out a better way to do this.  He can get a spreadsheet that has all the keywords and filenames out of his database, and what we'd like to do is have a Photoshop script that can read in that CSV file, and then scan a directory for TIFF images with those filenames, and write the appropriate keywords onto those TIFF images.
    Is this possible?  I'm eager to hear feedback on this.  Right now he's got a slew of 1800 images that he got on slide film from photographers, and has scanned, but hasn't written the IPTC keywords to yet.  If we can use this process on those, that would be great.
      -Josh

    Hi Paul and Mark,
    That link Paul posted looks very promising.  I'll have to test it out.
    One question: is there anywhere I can get Adobe Bridge CS4?  Since that's what my client has, that's what I'd like to test with.  I've been looking but can't find anything but the most recent version (CS5) for trial download.
      -Josh

  • Tiff writing

    Hi,
    my problem is the following:
    I'm are currently using Labview 5.1 and IMAQ visions 4.1 (I know its old but worked fine till now )).
    I need to acquire and save at a speed of about 3-5 pictures per second and save the files during almost 15 mins.
    My problem is that the "Write Tiff file" in IMAQ is too slow, it needs about 150 ms per acquisition and this way it needs almost more time to write to disk than to acquire our data.
    Is there a faster .VI somewhere around or how do I write to a buffer big enough to handle all the data while I'm still acquiring ?
    Does anyone know, why the .vi takes "that" (sure its still quick ;o))long? What parameters does it depend on ?
    Thanks

    TIFF (Tag Image File Format) is one of the oldest and most feature-rich bitmap formats around. It is still the format of choice for graphic artists. It has a plethora of options, many of which can slow you down. It is not well supported by inexpensive software due to its complexity. That said, you can get lots of info about it on the web. Here is a portal that may point you in the right direction:
    http://www.faqs.org/faqs/graphics/fileformats-faq/part3/section-147.html
    You disk write speed is something under 500k/sec, so something is obviously wrong. It may be that the IMAQ routine takes awhile to format the image into a TIFF file. Try a different format (e.g. GIF or PNG). Don't use compression - it will slow you down. This holds true for TIFF, GIF, and PNG, all of which support compression (last I checked, TIFF supported six or more compression modes).
    Good luck!
    This account is no longer active. Contact ShadesOfGray for current posts and information.

  • Resizing a TIFF File: Overwriting TIFFFields does not have any effect

    Hi,
    I have some TIFF files that I am receiving through a FAX server. Some of the TIFF files have an image length of *1077 pixels and a DPI of 200x98*. These images open fine in generic viewers like Microsoft Image Viewer and IrfanView and the image size in the information dialog shows up fine (1752x2158). But when I open the images in a LeadTools viewer (that works off TIFF Header tags), the image appears stretched out.
    I am trying to re-sample the image to make it a true Letter size image (1700x2200) with resolution of 200x200. I have been able to set the TAG_X_RESOLUTION and TAG_Y_RESOLUTION which I can see changed in the Tag Viewer. But changing the following tags does not have any effect on the resulting image:
    TAG_IMAGE_WIDTH
    TAG_IMAGE_LENGTH
    TAG_ROWS_PER_STRIP
    the following is the code I am using, I have tried all possible ways (removing TIFFFeilds and then adding them), but it has no effect. The last options is to use a Print Driver from within Java and Print the image (that re-samples it into a 8.5x11 inch image with 200 DPI). At this point, I am just curious about writing TIFFFields with images. Any ideas are appreciated:
    Thanks,
    Manuj
    +
    import java.io.BufferedOutputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.util.Iterator;
    import javax.imageio.IIOImage;
    import javax.imageio.ImageIO;
    import javax.imageio.ImageReader;
    import javax.imageio.ImageWriter;
    import javax.imageio.metadata.IIOMetadata;
    import javax.imageio.stream.ImageInputStream;
    import javax.imageio.stream.ImageOutputStream;
    import org.w3c.dom.NamedNodeMap;
    import org.w3c.dom.Node;
    import com.sun.media.imageio.plugins.tiff.BaselineTIFFTagSet;
    import com.sun.media.imageio.plugins.tiff.TIFFDirectory;
    import com.sun.media.imageio.plugins.tiff.TIFFField;
    import com.sun.media.imageio.plugins.tiff.TIFFImageWriteParam;
    import com.sun.media.imageio.plugins.tiff.TIFFTag;
    import com.sun.media.imageioimpl.plugins.tiff.TIFFT6Compressor;
                   //set the input stream for to the reader
                   tiffFileReader.setInput(tiffFileInputStream);     
                   //define the writer
                   ImageWriter tiffWriter = (ImageWriter) ImageIO.getImageWritersByMIMEType("image/tiff").next();
                   //define the writer param with compression;
                   TIFFImageWriteParam writeParam = (TIFFImageWriteParam)tiffWriter.getDefaultWriteParam();
                   TIFFT6Compressor compressor = new TIFFT6Compressor();
                   writeParam.setCompressionMode(TIFFImageWriteParam.MODE_EXPLICIT);
                   writeParam.setCompressionType(compressor.getCompressionType());
                   writeParam.setTIFFCompressor(compressor);
                   writeParam.setCompressionQuality(Float.parseFloat("1"));
    // get the metaData
                   IIOMetadata imageMetadata = null;
                   IIOImage testImage = null;
                   for(int i=0;i<filePageCount;i++)
                        imageMetadata = tiffFileReader.getImageMetadata(i);
                        TIFFDirectory dir = TIFFDirectory.createFromMetadata(imageMetadata);
              // Get {X,Y}Resolution tags.
              BaselineTIFFTagSet base = BaselineTIFFTagSet.getInstance();
              TIFFTag tagXRes = base.getTag(BaselineTIFFTagSet.TAG_X_RESOLUTION);
              TIFFTag tagYRes = base.getTag(BaselineTIFFTagSet.TAG_Y_RESOLUTION);
              TIFFTag tagImageWidth = base.getTag(BaselineTIFFTagSet.TAG_IMAGE_WIDTH);
    TIFFTag tagImageLength = base.getTag(BaselineTIFFTagSet.TAG_IMAGE_LENGTH);
              TIFFTag tagRowsPerStrip = base.getTag(BaselineTIFFTagSet.TAG_ROWS_PER_STRIP);
              TIFFField fieldRowsPerStrip = new TIFFField(tagRowsPerStrip, TIFFTag.TIFF_SHORT, 1, (Object)new char[]{2200});
              // Create {X,Y}Resolution fields.
              TIFFField fieldXRes = new TIFFField(tagXRes, TIFFTag.TIFF_RATIONAL,1, new long[][] {{200, 1}});
              TIFFField fieldYRes = new TIFFField(tagYRes, TIFFTag.TIFF_RATIONAL,1, new long[][] {{200, 1}});
              // Create Width/Height fields.
              TIFFField fieldImageWidth = new TIFFField(tagImageWidth,TIFFTag.TIFF_SHORT,1, (Object)new char[]{1728});
              TIFFField fieldImageLength = new TIFFField(tagImageLength, TIFFTag.TIFF_SHORT,1, (Object)new char[]{2200});
              //TIFFTag imageLengthTag = fieldImageLength.getTag();
              // Append {X,Y}Resolution fields to directory.
              dir.addTIFFField(fieldXRes);
              dir.addTIFFField(fieldYRes);
              //add Image Length and height parameters
              dir.addTIFFField(fieldImageWidth);
              dir.addTIFFField(fieldImageLength);
              // dir.removeTIFFField(278);
              dir.addTIFFField(fieldRowsPerStrip);
    testImage = new IIOImage(tiffFileReader.read(i), null, dir.getAsMetadata());
    +
    The resulting image with this carries the updated DPI values (200x200) but still carries the old values of 1752x1077, the length being exactly half of what Irfan view is showing.
    Edited by: Manuj on Nov 2, 2010 10:48 AM

    Your problem for some reason sounds familiar.
    EDIT
    Ok, now I remember. Your post is like this one in the old forums,
    http://forums.sun.com/thread.jspa?forumID=540&threadID=5425983
    Basically, for viewing purposes Irfanview scales the image's height by 2 and changes the dpi to *200x196*. It does this to achieve a 'square' pixel. The image that appears on screen now looks roughly how a printer would print it. However, the image data is still the same squished 1752x1077 image.

  • Server goes out of memory when annotating TIFF File. Help with Tiled Images

    I am new to JAI and have a problem with the system going out of memory
    Objective:
    1)Load up a TIFF file (each approx 5- 8 MB when compressed with CCITT.6 compression)
    2)Annotate image (consider it as a simple drawString with the Graphics2D object of the RenderedImage)
    3)Send it to the servlet outputStream
    Problem:
    Server goes out of memory when 5 threads try to access it concurrently
    Runtime conditions:
    VM param set to -Xmx1024m
    Observation
    Writing the files takes a lot of time when compared to reading the files
    Some more information
    1)I need to do the annotating at a pre-defined specific positions on the images(ex: in the first quadrant, or may be in the second quadrant).
    2)I know that using the TiledImage class its possible to load up a portion of the image and process it.
    Things I need help with:
    I do not know how to send the whole file back to servlet output stream after annotating a tile of the image.
    If write the tiled image back to a file, or to the outputstream, it gives me only the portion of the tile I read in and watermarked, not the whole image file
    I have attached the code I use when I load up the whole image
    Could somebody please help with the TiledImage solution?
    Thx
    public void annotateFile(File file, String wText, OutputStream out, AnnotationParameter param) throws Throwable {
    ImageReader imgReader = null;
    ImageWriter imgWriter = null;
    TiledImage in_image = null, out_image = null;
    IIOMetadata metadata = null;
    ImageOutputStream ios = null;
    try {
    Iterator readIter = ImageIO.getImageReadersBySuffix("tif");
    imgReader = (ImageReader) readIter.next();
    imgReader.setInput(ImageIO.createImageInputStream(file));
    metadata = imgReader.getImageMetadata(0);
    in_image = new TiledImage(JAI.create("fileload", file.getPath()), true);
    System.out.println("Image Read!");
    Annotater annotater = new Annotater(in_image);
    out_image = annotater.annotate(wText, param);
    Iterator writeIter = ImageIO.getImageWritersBySuffix("tif");
    if (writeIter.hasNext()) {
    imgWriter = (ImageWriter) writeIter.next();
    ios = ImageIO.createImageOutputStream(out);
    imgWriter.setOutput(ios);
    ImageWriteParam iwparam = imgWriter.getDefaultWriteParam();
    if (iwparam instanceof TIFFImageWriteParam) {
    iwparam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
    TIFFDirectory dir = (TIFFDirectory) out_image.getProperty("tiff_directory");
    double compressionParam = dir.getFieldAsDouble(BaselineTIFFTagSet.TAG_COMPRESSION);
    setTIFFCompression(iwparam, (int) compressionParam);
    else {
    iwparam.setCompressionMode(ImageWriteParam.MODE_COPY_FROM_METADATA);
    System.out.println("Trying to write Image ....");
    imgWriter.write(null, new IIOImage(out_image, null, metadata), iwparam);
    System.out.println("Image written....");
    finally {
    if (imgWriter != null)
    imgWriter.dispose();
    if (imgReader != null)
    imgReader.dispose();
    if (ios != null) {
    ios.flush();
    ios.close();
    }

    user8684061 wrote:
    U are right, SGA is too large for my server.
    I guess oracle set SGA automaticlly while i choose default installion , but ,why SGA would be so big? Is oracle not smart enough ?Default database configuration is going to reserve 40% of physical memory for SGA for an instance, which you as a user can always change. I don't see anything wrong with that to say Oracle is not smart.
    If i don't disincrease SGA, but increase max-shm-memory, would it work?This needs support from the CPU architecture (32 bit or 64 bit) and the kernel as well. Read more about the huge pages.

  • I am writing to this forum to ask for help in determining whether Aperture will satisfy my needs when I switch from Windows to MAC in the near future.

     I am writing to this forum to ask for help in determining whether Aperture will satisfy my needs when I switch from Windows to MAC in the near future.  
    I am currently using Photoshop Elements 8 on Windows 7.  After several years of use, I am self taught and adequately proficient for an amateur.  What I didn't realize (until I started researching my upcoming migration on the Internet) is that I actually use PE8 for two functions: digital asset management and digital editing. 
    Regarding Digital Asset Management: My research leads me to understand that PE on MAC does not provide the same level of organizational capability that I am used to having on Windows, instead providing Adobe's Bridge which does not look very robust.  Furthermore, iPhoto, which come on MAC will not support the hierarchical keyword tagging that I require to organize my library of photos. The two SW applications which I am thinking of switching to are either Aperture or Adobe's Lightroom.  Frankly, I'm thinking that it would be smoother to stay within the Apple product line. 
    So the remaining question is whether Aperture will support my digital editing needs. The tweaks that I do to my photos are not very complex (no, I do not want to put people's heads on other animal bodies).  But could someone who uses Aperture tell me whether It will allow me to do the following kinds of edits?:
    - If I have a photo where someone's face is too shadowed, can I lighten just that person's face, and leave the rest of the photo as-is?  
    - if I have a photo where the background is cluttered (eg, 2 people in front of the Parthenon which is undergoing renovation), can I remove just the construction cranes?  
    - Can it splice together several separate photos to give a panoramic?  
    If, once I get Aperture, I find that it cannot enable the kinds of editing that I do, I would probably get PE11 in the future. However, if people in this forum tell me that Aperture will definitely not  support the kinds of editing which I've described in the previous paragraph, I would prefer to get PE11 with my initial configuration (since someone will be helping me with my migration).  
    Thanks in advance for your consideration and help! 

    I am concerned, however,  about using a non-Apple Digital Asset Manager in OSX. I would really like to avoid integration problems. Is using PE11 to import and catalog my digital photos likely to cause conflicts?
    Thanks for any insight on this
    Amy,
    Not so much conflicts as maybe a little less seamless integration with Apple software and perhaps some third-party software providers in the Mac App Store where some programs build in direct access to iPhoto and Aperture libraries for getting images into those programs easily. Typically, there is a manual command to go to Finder (think Windows Explorer) to browse folders.
    One caution to mention however, is that the organization you set-up in PE Organizer is unlikely to transfer over to either iPhoto or Aperture if you decide to change at some point.
    The only real stumbling block that I see in your opening comment is that you want hierarchical keywording (Kirby or Léonie can go into the details on keywording limitations as I stay at one level). If you can work with the keywording schemes of either iPhoto or Aperture, then using PE for your external editor (either program supports setting an external editor) would probably be ideal since you know PE well. This is the idea with the Mac App Store version of PE (editor with no organizer).
    Note - I use Photoshop CS6 (full version) with Aperture and it works really well. The only downside is that Aperture has to make either a TIFF or PSD file to send to an external editor so that the original file is protected by not sending it to the pixel editor. While TIFF or PSD files protect the integrity of the image information without degrading it, they are typically much larger file sizes on disk than either RAW or JPEG files. Therefore, your library size (iPhoto or Aperture) will balloon quite a bit if you send a lot of files to external editors.
    One other possibility for an external editor would be a program called Pixelmator. It is pretty similar to early versions of Photoshop, but built for Mac. Other than the panoramics you want, it will do most pixel editing that PE can do. It is not an organizer, so it is built to go with either iPhoto or Aperture. It does have differences in how you complete certain procedures, so there is bit of a learning curve when you are used to doing it the Adobe way.

Maybe you are looking for

  • Office 2007 XLSX Support

    hi, I am looking for a solution that can help me in some standard way to support xlsx support to my ECC6 EHP 4 System. I want if alv is exported ( any alv report program) in excel it should generate xlsx file Office 2007 standard xlsx file to save. I

  • Using SharePoint OOTB search with external DB

    Hi All, I am using SharePoint OOTB search to search for documents inside a document library. The document library has all the data except for two cases: 1- Value stored in SharePoint document library as ID but the actual name is in an external DB (ex

  • Flex 3 Shape/Sprite Cylinder

    Hello all, I am trying to develop a simple data visualisation of a cylinder that the user can manipulate, either broadening the circumference (through some mouse event) or increasing the height. However, I am finding it difficult to develop this shap

  • Correlation Conflict inside BPEL

    Hi , I am getting correlation conflict inside the BPEL process. Can any body suggest some solution to it. Conflicting receive. A similar receive activity is being declared in the same process. Another receive activity or equivalent (currently, onMess

  • Cannot create new presets in AME CC 2014

    Whenever I go into AME CC 2014 and try and create a new preset, this is what I see: Strange Adobe Media Encoder CC 2014 Bug - YouTube. Also, whenever I quit AME, even when it's running idle, just sitting there not doing anything, I always get the une