How to retain the same resolution while croping a tiff image using jai api

Hi all,
I have designed a program to crop a tiff image.But after croping the tiff,the resultant file resolution is not the same as the original source file.
In the program,the source file Nadeshiko_v1_02.tif has the resolution(X) of 1200 DPI and resolution(Y) has 1200 DPI pixels.
But after croping the resolution of output file is 100 DPI.
Please give me some idea on how to retain the same resolution.
<code>
package jai;
import java.awt.Frame;
import java.awt.image.RenderedImage;
import java.awt.image.renderable.ParameterBlock;
import java.awt.image.renderable.RenderableImage;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.imageio.*;
import javax.imageio.stream.ImageOutputStream;
import javax.media.jai.Interpolation;
import javax.media.*;
import javax.media.jai.JAI;
import javax.media.jai.PlanarImage;
import javax.media.jai.RenderedOp;
import javax.media.jai.widget.ScrollingImagePanel;
import com.sun.media.jai.codec.FileSeekableStream;
import com.sun.media.jai.codec.SeekableStream;
import com.sun.media.jai.codec.TIFFEncodeParam;
import javax.media.jai.OperationDescriptorImpl;
import java.io.*;
import java.util.Iterator;
import javax.media.jai.operator.*;
// import javax.media.jai.widget.ScrollingImagePanel;
public class crop {
          /** The main method. */
public static void main(String[] args) {
/* Validate input. */
/* if (args.length != 1) {
System.out.println("Usage: java JAISampleProgram " +
"input_image_filename");
// System.exit(-1);
float a=(float) 70.3;
float b=(float) 70.4;
float c=(float) 3100.3;
float d=(float) 5522.4;
* Create an input stream from the specified file name
* to be used with the file decoding operator.
String TIFF="TIFF";
FileSeekableStream stream = null;
try {
     stream = new FileSeekableStream("D:\\tif images\\Nadeshiko_v1_02.tif");
// stream = new FileSeekableStream("D:\\tif images\\Nadeshiko_v1_01.jpg");
} catch (IOException e) {
e.printStackTrace();
System.exit(0);
// Load the source image from a Stream.
RenderedImage im = JAI.create("stream", stream);
RenderedImage image2= CropDescriptor.create(im, a, b, c, d, null);
ScrollingImagePanel panel = new ScrollingImagePanel(image2, 100, 100);
// Create a frame to contain the panel.
Frame window = new Frame("JAI Image Cropping");
window.add(panel);
window.pack();
// window.show();
// Define the source and destination file names.
// String inputFile = "D:\\tif images\\Nadeshiko_v1_05.tif";
String outputFile = "D:\\tif images\\Nadeshiko_v1_04.tif";
// Save the image on a file. We cannot just store it, we must set the image encoding parameters
// to ensure that it will be stored as a tiled image.
TIFFEncodeParam tep = new TIFFEncodeParam();
tep.setWriteTiled(true);
tep.setTileSize(80,80);
JAI.create("filestore",image2,outputFile,"TIFF",null);
try {
               stream.close();
          } catch (IOException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
</code>
Thanks,
Sanat Meher

Try the following,
TIFFEncodeParam tep = new TIFFEncodeParam();
// Create {X,Y}Resolution fields.
TIFFField fieldXRes = new TIFFField(0x11A, TIFFField.TIFF_RATIONAL,
                                    1, new long[][] {{DPI_X, 1}});
TIFFField fieldYRes = new TIFFField(0x11B, TIFFField.TIFF_RATIONAL,
                                    1, new long[][] {{DPI_Y, 1}});
tep.setExtraFields(new TIFFField[] {fieldXRes, fieldYRes});

Similar Messages

  • How to retain the same input filename with FileAdapter

    I use FileAdapter to read a file. I need to archive the file using the same filename. So I copied the input file to another FileHeader then write the file to the archived directory using FileAdapter. But the archived file does not retain the original filename. Here is a section of my code:
    <variable name="Variable_FileHeader" element="ns2:InboundFileHeaderType"/>
    <variable name="Variable_Archive_FileHeader" element="ns2:OutboundFileHeaderType"/>
    <receive name="Receive_FileReader" partnerLink="FileReader" portType="ns1:Get_ptt" operation="Get"
    variable="Receive_FileReader_Get_InputVariable" createInstance="yes" bpelx:headerVariable="Variable_FileHeader"/>
    <assign name="Archive">
    <copy>
    <from variable="Receive_FileReader_Get_InputVariable" part="opaque"/>
    <to variable="Invoke_Archive_Put_InputVariable" part="opaque"/>
    </copy>
    <copy>
    <from variable="Variable_FileHeader" query="/ns2:InboundFileHeaderType/ns2:fileName"/>
    <to variable="Variable_Archive_FileHeader" query="/ns2:OutboundFileHeaderType/ns2:fileName"/>
    </copy>
    </assign>
    <invoke name="Invoke_FileArchive" partnerLink="FileArchive" portType="ns3:Put_ptt" operation="Put"
    inputVariable="Invoke_Archive_Put_InputVariable" bpelx:headerVariable="Variable_Archive_FileHeader"/>
    in the FileArchive.wsdl, I did not remove the FileNamingConvention line because if I removed it, the compiler will complain:
    <jca:operation
    PhysicalDirectory="D:\projects\Butterfield Bank\BPEL-ESB\FileConverter\files_archived"
    InteractionSpec="oracle.tip.adapter.file.outbound.FileInteractionSpec"
    FileNamingConvention="Archive_%SEQ%.txt" <=== what should I put here to retain the same filename?????
    OpaqueSchema="true" >
    </jca:operation>
    The file being archived still have the convention Archive1.txt and not using the original filename.
    Thanks for any help
    AJ

    Hi,
    I have done the same thing and I don't face any problem. Below is the code:
    <variables>
    <variable name="Receive_1_Read_InputVariable" messageType="ns1:Read_msg"/>
    <variable name="Invoke_1_Write_InputVariable" messageType="ns2:Write_msg"/>
    <variable name="InFile" messageType="ns4:InboundHeader_msg"/>
    <variable name="OutFile" messageType="ns4:OutboundHeader_msg"/>
    </variables>
    <!--
    ORCHESTRATION LOGIC
    Set of activities coordinating the flow of messages across the
    services integrated within this business process
    -->
    <sequence name="main">
    <receive name="Receive_1" partnerLink="Read" portType="ns1:Read_ptt"
    operation="Read" variable="Receive_1_Read_InputVariable"
    createInstance="yes" bpelx:headerVariable="InFile"/>
    <assign name="Assign_1">
    <copy>
    <from variable="Receive_1_Read_InputVariable" part="opaque"
    query="/ns3:opaqueElement"/>
    <to variable="Invoke_1_Write_InputVariable" part="opaque"
    query="/ns3:opaqueElement"/>
    </copy>
    <copy>
    <from variable="InFile" part="inboundHeader"
    query="/ns4:InboundFileHeaderType/ns4:fileName"/>
    <to variable="OutFile" part="outboundHeader"
    query="/ns4:OutboundFileHeaderType/ns4:fileName"/>
    </copy>
    </assign>
    <invoke name="Invoke_1" partnerLink="Write" portType="ns2:Write_ptt"
    operation="Write" inputVariable="Invoke_1_Write_InputVariable"
    bpelx:inputHeaderVariable="OutFile"/>

  • How To Perform The Same Edit And Crop To Multiple Images?

    On just one image this would be a no brainer, I'd just use the paint brush or similar tool to wipe over a section I want covered and use the crop tool to get the image size and position I'm after. The thing is though, I'd like to do the same edit and crop to a series of photos to keep them all consistent and it's beyond me how to do that in PS5. When I look at help I find tips on using scripts, batch processing or stacking images that seem to defy the English language and don't address the two simple little things I want to do to these images.
    Can anyone explain, or point me to a resource, that could help me accomplish what I'd like to think should be a simple task for such an expensive program?
    Greg

    You could use a "clipper" document to isolate the globe in each image.
    Create a clipper doc which is the size of the images in the globe series and which contains only a layer with a silhouette of the globe surrounded by transparency.
    Make an Action which will copy the current image and close it, paste into the already open clipper doc, clip that image layer to the silhouette layer, crop/trim, export a file then revert the clipper doc to its initial state of just the silhouette ready for processing the next image in the batch. For example:
    1. Select All
    2. Copy
    3. Close
    4. Paste
    5. Create Clipping Mask
    6. Trim based on transparent pixels
    7. Save As
    8. Revert
    Open the clipper doc then set up Batch so the output files are named with a serial number.

  • I cannot get the same colors when I print an image using Elements 12 (way off) and iPhoto (Close to Monitor color)

    My image colors are over saturated and off in tone when I try to print with Elements 12 but if I take the same image in to iPhoto the colors are much closer to what I see on the monitor.  There does not seem to be a way to match the color profile of iPhoto .
    Do you have a suggestion?

    Epson replied
    Thank you for contacting Epson regarding your Epson Stylus Photo R2880.
    We have seen an increase in calls of users using 10.7/10.8 with darkness or color issues. We do know this issue is coming from Adobe programs and they are aware of it and have told customers to test this by printing a photo from Apples Preview program, something other than an Adobe program. So if you right click on a jpeg file and select "open with", choose Preview and make settings here and print, the print should come out more like you are used to seeing. If it comes out normal, then this will tell you the program is the issue and you will need to contact Adobe for a fix or an update.
    I subsequently did a color test print with Preview  from an exported photo from Lightroom 4. I used Color Sync to manage the color with my icc profile to match the paper. The color came out perfectly. I then printed the picture with LR  having the application manage the color and the reds remain washed out with an unacceptable print.
    So it looks like the problem is with Adobe, not Epson.

  • How to retain the format in MS word when creating PDF using arabic fonts.

    I have a word document using Arabic fonts. When I create the PDF, it looses all the formatting. Can someone help me solve this issue. Thank you.

    Hi Ricol -
    Thanks for reporting the issue.
    We would need the files for investigation. Request you to share your email id for correspondence.
    Regards,
    Reetika

  • How do I keep my daughter and I's apps and contact info SEPERATE on the same itunes while sharing songs?

    How do I keep my daughter and I's apps and contact info SEPERATE on the same itunes while sharing songs?
    I need step by step directions on set up different profiles on itunes for 2 seperate iphones. I want to be able to share purchases if desired, but not have to have the same apps/songs on our phones. I could do with sharing songs.....apps not so much. Please Help!!
    Thank You

    This should help:
    How to use multiple iPods, iPads, or iPhones with one computer
    Regards.

  • How can i stop user to get the same screen while entering same T code

    hi experts,
    how can i stop user to get the same screen while entering same T code (_Means i want user enter same t code but got different different screen how it is possible.)_
    i want to know how can we set a authorization is such a manner ...
    Through different different login id user got different different screen while entering same T-code.
    for example if there is two functional login id mum & noida...
    then user login through that and
    enter any same functional tcode (for getting purchase order)
    but get different different window...so how come it is possible.....
    plz explain in brief
    thanks in advance...plz do reply as soon as possible

    For a custom transaction this is easy, you need to ask your developers to be able to direct users to different screens based on the results of an authorisation check.  You could have an auth field e.g. ZSCREEN which is checked in the program & decides what screen the user has access to.
    For standard transactions, unless already coded, I would forget it & do what is recommended by Subramaniam and create transaction variants as required.  Assign each variant to a custom t-code and users access it that way.
    What I am interested is is why do you want to do this?

  • How to retain the button over state while scrolling over a Pop-up Menu

    Are there updated instruction for Fireworks 8?
    http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_15926&sliceId=1

    I just wouldn't use those menus at all - there are much
    better ways. Have
    you considered them?
    Check the uberlink and MacFly tutorials at PVII -
    http://www.projectseven.com/
    and the Navbar tutorial/articles at Thierry's place
    http://tjkdesign.com/articles/dropdown/
    Or this one (more recent article):
    http://tjkdesign.com/articles/Pure_CSS_Dropdown_Menus.asp
    Or to get it done fast, go here -
    http://www.projectseven.com/tutorials/navigation/auto_hide/index.htm
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "turpya" <[email protected]> wrote in
    message
    news:f2ilfs$7gr$[email protected]..
    > Hi,
    >
    > I am trying to work out how to retain button over state
    while scrolling
    > over a
    > pop-up menu. By default the button changes back to mouse
    out state, when
    > scrolling over menu items for that button.
    >
    > I have tried to follow the advice in the below technote
    (see link below),
    > but
    > it seems the instructions are incorrect.
    >
    > I am using Fireworks 8 - it appears the instructions are
    for a prior
    > version.
    > I cannot find function fwLoadMenus() mentioned in Step 3
    (number 6.).
    >
    > Has anyone accomplished this in Fireworks 8, that could
    provide me with
    > instructions?
    >
    > Thanks in advance,
    >
    > turpya.
    >
    >
    http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_15926
    >

  • How comes the Ipad mini isn't Retina Display if it has the same resolution as the New iPad?

    How comes the Ipad mini isn't Retina Display if it has the same resolution as the New iPad?

    The iPad mini doesn't have the same resolution as the "new iPad".
    iPad 3 & 4 (retina) = 2048x1536 pixels
    iPad 1 & 2 (original) = 1024x768
    iPad mini = 1024x768
    Apple likely didn't put a retina screen in the iPad mini to keep cost down and to have an option to upgrade the iPad mini to a retina screen down the road, in a year or two.  It could be however that the pixel density of 2048x768 at 9" poses a problem for the viewer, in that text and features might be rendered too small or too thin for the average buyer/consumer.

  • Images the same resolution as screen get scaled

    Images that have the same resolution as the screen on either plane are not fully pixel mapped when shown in full, but suffer a loss in sharpness along the center axis due to scaling. While not readily visible in most images, it is an undesirable and unnecessary artifact.
    Replication steps:
    1. Create an image the same resolution as the phone's screen, e.g. 1080x1920 pixels, and fill it with a 2x2 pixel checkerboard pattern (every other pixel white and every other pixel black). Save it as PNG, or as JPEG with minimum compression.
    2. Copy the image to the phone (e.g. the Pictures folder).
    3. View the image at full size using Album, oriented the same direction as the screen such that it should display pixel mapped.
    4. Observe the loss of sharpness that occurs as neighboring pixel values are blended in areas of the image.
    This problem was observed on an Xperia Z3 with Album version 6.6.A.0.6 and earlier.
    I'll try putting together some examples later and add them to this thread.

    iPod:
    4-inch (diagonal) widescreen display with Multi-Touch IPS technology
    Retina display
    1136-by-640-pixel resolution at 326 pixels per inch
    800:1 contrast ratio (typical)
    500 cd/m2 max brightness (typical)
    Fingerprint-resistant oleophobic coating
    iPhone:
    Retina display
    4-inch (diagonal) widescreen Multi-Touch display
    1136-by-640-pixel resolution at 326 ppi
    800:1 contrast ratio (typical)
    500 cd/m2 max brightness (typical)
    Fingerprint-resistant oleophobic coating on front
    Support for display of multiple languages and characters simultaneously

  • How to handle the table control While working with LSMW?

    How to handle the table control While working with LSMW?

    its possible in lsmw,
    Hi,
    LSMW will have a Indicator for headr and itam, i do not remember the correct field, but it will have an indicator, check the fields, there will be a single charecter lenght field, that should be the indicator, and using that we can write the logic.
    check that single charecter field, it that is X that means the header record is processed, and do the items.
    and, this is another way, try this out also
    YOu can do this in "Define Source Structures" step,
    the HEADER is defined first,
    then the DETAIL below the HEADER.
    add the fields to the structures.
    Both should have some common key field
    Please take care that the name of the common field is the same.
    Once you do this it is linked. The you have a header and item corresponding to that header. then run the LSMW as you would.
    Thanks

  • How to export the same mb size of my cr2 files into jpg or tiff files in Lr?

    How to export the same mb size of my cr2 files into jpg or tiff files in Lr?
    Let's say my file size is 22mb, when i export the file to tiff or jpg, although Iam careful with the settings- file size, dimension, resolution, I can't manioukate how I want it.
    With jpg I tried everything, no matter what i do or change in files size or resoltion it remains the same size- 7mb as opposed to 22..
    Please advise,
    Best wishes,
    T

    I would noramlly opt for a tiff file, sending such a high res through the nest a nightmare
    This is probably just an improper use of terminology, but the resolution of a JPG, DNG and TIF should all be the same.
    The files differ in size, not resolution and not number of pixels.
    Jpg is not that bad, but its a pitty they have to be edited under a jpg format..
    Your raws are edited as raw. There is no loss of quality in the editing process. The files are then exported as JPG, which will cause a loss of quality. For just about any use, the loss of quality in the image when you export a JPG at quality level 12 is NOT noticeable. For many uses, exporting a JPG at a quality level of 8 will not be noticeable either, unless you intend to print the photo at a very large size. As twenty_one (not his real name) said, "Jpeg compression is fantastically effective".

  • How to improve the load performance while using Datasources for the Invoice

    HI All,
    How to improve the  load performance while using Datasources for the Invoice . Actually my invoice load (Appx. 0.4 M records) is taking very long time nearly ~16 to 18 hrs  to update data from R/3 to 0ASA_DS01.
    If I load through flat file it will load with in ~20 Min for the same amount of data.
    Please suggest how to improve load performance.
    PS: I have done the Inpo package settings as per the OSS note.
    Regads
    Srininivasarao.Namburi.

    Hi Srinivas,
    Please refer to my blog posting [/people/divyesh.jain/blog/2010/07/20/package-size-in-spend-performance-management-extraction|/people/divyesh.jain/blog/2010/07/20/package-size-in-spend-performance-management-extraction] which gives the details about the package size setting for extractors. I am sure that will be helpful in your case.
    Thanks,
    Divyesh
    Edited by: Divyesh Jain on Jul 20, 2010 8:47 PM

  • "Data only" csv export. How to get the same data?

    When I export to csv I get more data than when exporting to "data only". Why and how to get the same as when using "data only". I suppose it is because of some supressed lines, but why there is difference in the view (which is right) and in the export file?
    I do not want to export to xls with "data only" and save as csv, because the exported csv is being read by another application, which is unable to convert it automatically.
    The other way is to put constraints in the data selection for the whole report (and not by supressing lines). How to say {table.date}>=maximum({table.date}) in the  in the data selection? There is not possible to use "maximum". Probably possible with array?
    Thanks in advance
    Edited by: Kiril Bojilov on Aug 4, 2009 12:34 PM
    Ok, I managed it: I put the constraint in the group selection
    Edited by: Kiril Bojilov on Aug 4, 2009 12:46 PM

    New customers get more options because new customers didn't already agree to complete a 2yr contract before being able to get a new phone. If you had a line that wasn't under contract, you would get a better deal than new customers because while they pay $35 activation fee for a new line, you pay $30 upgrade fee for using an upgrade. You just have to finish your end of the deal before you can start a new one.

  • Is there a way to automatically add another of the same page while a form is being filled?

    Is there a way to automatically add another of the same page while a form is being filled?
    I have a two-page form of which the second page is essentially a spreadsheet analog.  Often, there is need for for more lines than are available on the page.  Is there a way in which to add another or even multiple copies of the second page? 
    Thanks ahead...
    TG

    You can do that with a dynamic XFA form created in LiveCycle Designer, which comes with Acrobat Pro for Windows. For more information, you can ask over at the LiveCycle Designer forum.

Maybe you are looking for

  • How to remove the lines above and below  header in sqlplus report

    I run a sql*plus report whch i want to be outputted to XLS file. But the format is not matching. I am using data->texttocolumns feature of excel , which is manual . As the headers are coming dynamically from query . i CAN NOT set header off. So first

  • Obiee 11g 11.1.1.6 Action links not taking into consideration DashBoard Prompts

    I really hope someone can help. I have a dashboard with an analysis that has a column that is not shown but is prompted via dashboard prompts. This dashboard is a summary set of data and the column in question is deliberately exclude at the request o

  • Vista with Windows 7 upgrade

    If I get a Windows 7 upgrade disk and install it over my current Vista, and then upgrade to Lion, what will I have to do if I ever need to reinstall Windows 7 since I will only have it as an upgrade disk? I don't want to buy a full version for the on

  • CR2 files wont open on CS6

    I just downloaded some RAW CR2 files from my EOS 6D and tried uploading onto CS6 but I got a pop up saying the file cannot be opened using CS6 HOWEVER, CR2 files from my 5D MARK II opens just fine. Can someone please help me understand why this is?

  • App World IMPOSSIBLE!!!!!

    Hi there all! I simply can't download any apps on my Blackberry Bold 9900 and its very, very frustrating. I spoke with Vodafone, my service provider and we downloaded the latest app world, but it didn't help. The last person also deleted an account a