ImageIO encode split page with original params?

Hey all,
I'm working with TIFF's and the ImageIO library. I split out a single page from a TIFF and then re-encode it, but I can not figure out how to re-encode with the exact same configuration of the original TIFF (i.e. compression, resolution, white/black, etc.).
Is there some way to do this please? Attached is my working code if this helps!
-D
     Iterator writers = javax.imageio.ImageIO.getImageWritersByFormatName("tiff");
     javax.imageio.ImageWriter writer = (javax.imageio.ImageWriter)writers.next();
     ByteArrayOutputStream out = new ByteArrayOutputStream();
     javax.imageio.stream.ImageOutputStream ios = javax.imageio.ImageIO.createImageOutputStream(out);
     ImageReadParam rparam = imageReader.getDefaultReadParam();
     TIFFImageWriteParam writeParam = (TIFFImageWriteParam)writer.getDefaultWriteParam();
     writer.setOutput(ios);
     writer.write(iiometadata,iioimage,writeParam);
     ios.flush();
     return out.toByteArray();

I'll answer my own question. Key is to copy and/or edit the Node object representing the image's metadata. This is an XML representation of the TIFF tags.
In this example, all the input images properties are encoding in the output image.
            ImageReader reader ...
            ImageWriter writer ...
            BufferedImage bi = reader.read(0);
            IIOMetadata metaData = reader.getImageMetadata(0);
            Node node = metaData.getAsTree("com_sun_media_imageio_plugins_tiff_image_1.0");
            ImageOutputStream ios = ImageIO.createImageOutputStream(target);
            writer.setOutput(ios);
            IIOMetadata imageMetadata = writer.getDefaultImageMetadata(null, writeParam);
            imageMetadata.setFromTree("com_sun_media_imageio_plugins_tiff_image_1.0", node);
            IIOImage img = new IIOImage(bi, null, imageMetadata);
            writer.write(null, img, writeParam);

Similar Messages

  • How do I split pages with Adobe CreatePDF, is the funtionality part of the software?

    How do I split pages with Adobe CreatePDF, is the funtionality part of the software?

    No, it is not.

  • Reload the same page with multiple param id

    Hi dude,
    i create review.jsp and include the displayproduct.jsp.. when i add review for the particular product,value added succesfully in db and successurl method will call and reload the displayproduct.jsp as blank page.. because param id not passing in url..
    how to pass the previous navactionid,navcountid and productid to SuccessURL with same jsp..
    pls clarify my doubt..

    hi MishraI need to pass the param in button
    <dsp:input type="submit" bean="MyReviewFormHandler.addReview" value="Submit Review">
    <dsp:input bean="MyReviewFormHandler.ProductReviewSuccessURL" type="hidden" value="displayCategory.jsp" />
    >
    It should work.
    I'm using below same way and working fine.
    <%/* URL to go to if user's session expires while he is filling out this form */%>
         <dsp:input bean="ShoppingCartModifier.sessionExpirationURL" type="hidden" value="../../common/SessionExpired.jsp"/>
         <%/* ADD TO CART BUTTON: Adds this SKU to the Order*/%>
         <dsp:input bean="ShoppingCartModifier.addItemToOrder" type="submit" value="Add to Cart "/>
         <%/* Goto this URL if NO errors are found during the ADD TO CART button  processing:*/%>
         <dsp:input bean="ShoppingCartModifier.addItemToOrderSuccessURL" type="hidden"  value="../checkout/cart.jsp"/>-RMishra

  • Can I deploy pages with DB params stored elsewhere?

    Hello,
    Trying to get up to speed with JSP's. So far, all is well. Can go into, out, etc. of a DB, which is fine.
    Question is this. The pages that have all of the JDBC connection params in them, is it possible to put all of the DB params into a module page, and just import it, so I don't have a ton of duplicate code floating around the web site? If so, what's the best? Almost like a .h file in C++, but in Java, what are they called?
    Thanks,
    10k

    http://java.sun.com/products/jsp/syntax/1.2/syntaxref12.html
    You can use the <%@ include %> which is the equivalent of a .h file in c++
    It is a static include at page translation time, which effectively just "pastes" the code into your jsp.
    This way you can have a common header on all of your JSPs.
    However it is preferable NOT to do SQL queries/scriptlet code in JSP.
    Write a java bean that handles database connection, and call db.getConnection() on it.
    Or use JSTL sql tags
    Even better, don't have any SQL statements on your JSP pages - put it all into java beans as a data access layer.
    Cheers,
    evnafets

  • Printing web page with select tags in IE9 and a .cfm file-only the original selected option prints

    My web page has a select tag and cfselect tags and when I print the page with a different option other than the originally selected option the print for both types of select tags reverts back to the original selection and ignores the new selection.  This happens in IE9 and .cfm files but not when the page is printed in IE8 or IE7 modes (tried in the F12 Developer Tools.)  It also needs to be a .cfm file.  FireFox printed the pages correctly for any combination.
    This was done on a Dell and ThinkCentre computers under Windows 7.  Also, I was able to reproduce the same problem on an different university web site where a selection box would revert back to the original selection for printing on a .cfm page and would print properly on a .PHP page at the same site.
    For my site, I used a print button which calls print() and right clicked and chose print and got the same results no matter which method was used.  I only had the right click method on the third party web site.
    I know this is probably a bit narrow an issue but, any help would be appreciated.

    It appears that it is probably an IE9 bug.
    I simplified the problem by turning the page source taken from the brouser of the original .cfm into an html file and found that it would still print improperly.
    When I eliminated the various parts of the file I found that it would print correctly only when I removed the first line, the "DOC type" line.
    The page will print the newly selected option but then I lose the style sheet.
    If it does not work in an HTML file it must be IE.  It is not the .cfm.  The reason that it did not work for .cfm files, is that they always have a "DOC type" statement.
    I have put the issue into an MSDN forum in addition to the one mentioned previously.

  • On a long web page with many small pics Firefox (4.0.1 on Linux Mint 11) doesn't load them all at once, and MAFF replaces original pics with blank lazy.png

    Similar problem trying to save web page with ScreenGrab! (many small pics on the web page are blank). Maybe there is a way to fine tune Firefox?

    Does the ext directory have the php_oci8.dll? In the original steps the PHP dir is renamed. In the given php.in the extension_dir looks like it has been updated correctly. Since PHP distributes php_oci8.dll by default I reckon there would be a very good chance that the problem was somewhere else. Since this is an old thread I don't think we'll get much value from speculation.
    -- cj

  • How do i open a web page with VeriSign Class 3 Extended Validation SSL SGC SS CA certfificate i can't open web pages with this, how do i open a web page with VeriSign Class 3 Extended Validation SSL SGC CA certfificate i can't open web pages with this

    how do i open a web page with VeriSign Class 3 Extended Validation SSL SGC SS CA ?

    Hi
    I am not suprised no one answered your questions, there are simply to many of them. Can I suggest you read the faq on 'how to get help quickly at - http://forums.adobe.com/thread/470404.
    Especially the section Don't which says -
    DON'T
    Don't post a series of questions in  a single post. Splitting them into separate threads increases your  chances of a quick answer.
    PZ
    www.pziecina.com

  • Extract PDF pages with it's actual page numbers...

    Hi scripting gurus,
    We have more than 40 of PDF documents each document contain multiple pages. Using Acrobat Professional 7.0 and 8.0 with MAC platform. We have the script to extract the pages and to suffix running numbers with the document name, please find the script below. For example CH01.pdf document total number of pages is 10, but the actual page number starts with 11. So We have to extract each pages as individual documents and the page number will followed by document name with "_" separation, (Eg: CH01_11.pdf). I have tried so many ways to include the page numbers with the document name but i can't.
    /*Split pdf pages with pNum suffixed*/
    var rename = /.*\/|\.pdf$/ig;
    var startName = this.path.replace(rename,"");
    for (var i = 1, j = 0; j < numPages; i += 1, j += 1) {
    extractPages ({
    nStart : j,
    nEnd : j == numPages - 1 ? j : j + 0,
    cPath : "/Macintosh HD/Users/Beaconpmg/Desktop/ExtractFolder/"+startName+"_"+i+".pdf"
    So please can anyone look into this and help for me.
    Thanks in advance.
    Regards
    Thiyagu

    try67
    First of all, replace numPages with this.numPages
    Also, this doesn't make any sense:
    nEnd : i == numPages - 1
    I have tried what you have said above, but it is not working. Its showing the same error (missing ; before statement)in 4th line of the script.
    Please find the complete code below;
    // see if we need to define a global offset first file
    if(global.fPageOffset == undefined) {
    var global.fPageOffset = 10; // start at 10
    /*Split pdf pages with pNum suffixed*/
    var rename = /.*\/|\.pdf$/ig;
    var startName = this.path.replace(rename,"");
    for (var i = 0; i < this.numPages; i++) { this.extractPages ({ nStart : i, nEnd : i == this.numPages - 1 , cPath : "/Macintosh HD/Users/Beaconpmg/Desktop/ExtractFolder/" + startName + "_" + (i + global.PageOffset) + ".pdf" }); }
    // add finished file's number of pages to global page offest
    global.fPageOffest += this.numPages;
    Regards
    Thiyagu

  • I think I finished installing Mountain Lion, and am at the "log in" page with my name and the Lion icon, but I cannot do any of the functions on screen. That is, I cannot log in, sleep, restart, or shut down. I am running it on an Early 2009 Macbook Pro

    I think I finished installing Mountain Lion, and am at the "log in" page with the Mountain Lion icon, but I cannot do any of the functions on screen. That is, I cannot log in, sleep, restart, or shut down. I am running it on an Early 2009 Macbook Pro, which is said to have the capabilities of running Mountain Lion.

    BrettGoudy wrote:
    ...Is there any way I can install a partition that runs snow leopard on my early 2011 MB pro with what I have (new SSD, New RAM, Current version Lion running, no external drive, lack of original snow leopard disks [I lost them ] and the general 10.6.3 snow leopard boot disks)...
    As the last post suggests, call Apple and order a replacement original disc for about $17.  They will ask you the model and serial numbers.
    Your retail version of Snow Leopard OS 10.6.3 will not work on that Mac as it requires a minimum of OS X 10.6.7 to boot and operate.
    Another alternative is to again borrow another Mac to install your retail Snow Leopard into an external HD or partition, upgrade it to 10.6.8 and then clone it back to a partition on your MBP.

  • Error Handling On a Page with a Report

    Hi guys.
    I have a page with a report region on it. The report is based on an External Table.
    If i load a file that does not conform to the format the External Table definition is expecting, I Get an 'ORA-29913: error in executing ODCIEXTTABLEFETCH callout
    ORA-30653: reject limit reached' error.
    I am happy that an error is generated but my question is this?
    How can I handle this exception and others when there is just a report region on a page.
    I basically wish to capture 'ORA-30653: reject limit reached' and display an friendly error message to the user in the report region.
    Any help would be most welcome.
    Duncan

    One way to handle this that I have seen is
    a. configure your external table with REJECT LIMIT UNLIMITED
    b. specify a BADFILE badfile.txt.
    c. Create another external table on that badfile.txt with the same access parameters as your original table but specify all the columns as VARCHAR2(4000), so nothing is rejected.
    d. Create another report region on the external table on badfile.txt, call it "Load errors"
    So, you would have 2 report regions on the page, one would read your datafile and the other would read the badfile.
    Hope this helps.

  • Dynamic table header/footer on multiple pages stay original

    hi experts,
    i've got a form with a dynamic table. this means that i have a footerrow with mapped information if it should be visible or not. so the table can have from 1 to 40 columns.
    i did some scripting in the table's initialize section:
    loop over count of colums and set the headerrow, row1 and footerrow elements for index x to hidden.
    everything works out fine BUT if the data spans over multiple pages the headerrow on pages 2 to last is original again. means that the hiding of cells is not effective any more. same with footerrow (but here its fine at last page and original at  page 1 to last -1).
    i tried to hide cells again in layout:ready section for the other instances of the headerrow.
    cells got hidden, but the still visible cells didnt relocate to the left (if i hide it, there should be no space between staying cells).
    can anyone please give me a hint what i am missing here?
    does anyone have a simple sample for this task? its all about the header/footer for multiple pages!
    thanks a lot!
    daapoo

    When the footer goes to the 2nd page the page subform is incremented so you will have to reference the page subform as well. I suggest that you add a button (this is for a test only) to the footer subform and add the code app.alert(this.somExpression). Now render the form and make sure the footer stays on one page. Hit the button and take note of the someExpression. Now add enough rows to force the footer to a new page. Hit th ebutton again and take note of the changed somExpression. So to solve your problem you will have to find out which page your footer is on. and then construct your expression to incorporate this chane in expression. Note that the indexes are 0 based but the page numbering is 1 based.
    Hope that helps
    Paul

  • I have made an 8.5 x 11 flyer and want to create handbills, four to a page, with Photoshbe op or Ado

    I have made an 8.5 x 11 flyer and want to create handbills, four to a page, with Photoshop or Adobe Acrobat Pro. Waht do I do?

    Create a new document the size of the handbill 4-up {example if handbill is 3"X4" then the new document would be 6"X8" Plus an optional margin and bleed (don't forget to include the gutters between the handbills - The gutter is used for the opposite margin to make the white space around the individual handbill equal)}
    place the original document into the new document
    make sure the layers are grouped for easy moving
    Drag out guides from the ruler (make sure ruler is visible) - Make the guides for each edge of the page for the margin, 2 guides between where each document should be (both rows and columns) Readjust if necessary until it looks right
    Optional - Scale original document to fit the guides if necessary
    Alt drag the group to the next location
    Repeat 6
    I can't make it any more or less detailed without see something from your screen, when in doubt post screen shots

  • Applying a New Template to a Page with Tabs

    Hi,
    We use page templates for our pages. We know that you cannot add a region to a page based on a template, but supposedly you can add tabs to a page based on a template.
    One template we have has a single tab on it. The web designers have been adding content to pages built on that template. When they need another tab, they add it and add content to the new region on the tab. They may do this until there are 4 tabs on the page (the original tab that is in the template, plus three additional tabs). We use this for example to collect links to memos and to divide the links onto 4 tabs representing calendar quarters.
    One of the problems with this process is that the web designers have not been consistent in using uniform definitions for the region on each tab causing an inconsistent look-and-feel from one tab to the next.
    I have created a new template with 4 tabs already defined and with the region properties already defined. The web designers can then add content as needed and if a tab is not required it can be marked as hidden.
    The problem that I am running into is that if I try to apply the new template to an existing page, I get the following error message:
    Error: ORA-00001: unique constraint (PORTAL.WWV_THINGS_NAME_UK) violated
    Also, consistently the content from the original first tab is lost and there is no corresponding tab on the reformatted page. Content on the second tab appears to be OK, but content on the third tab is missing. Content on the fourth tab appears to be OK.
    Can anyone tell me 1. what is specifically causing the error message, and 2. is it possible to do what I want to do or will all of these pages have to be recreated manually instead of changing the templates.?
    Thanks,
    Peter

    You should be able to do what you are trying to do. You seem to be running into a bug. Please file this with support if possible. Based on the error message, you seem to be running into a case of duplicate names, on either items or tabs. What you might try doing is renaming the tabs, ensuring uniqueness, before changing templates. By "renaming", I mean changing the NAME of the tab, not the Display Name, by clicking Edit Tab in edit mode. Does this help at all?

  • Redirect page with POST method in JSTL

    how to redirect page with POST method in JSTL.
    below is the code that i make, but the page redirected with GET method,
    so, the URL shown as http://localhost:8080/tes2/coba2.jsp?nama=saya
    how to hide the parameter, so it didn't show at the URL..??
    anybody help me..??
    server1 -> coba1.jsp
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <html>
    <head>
    <title>coba1</title>
    </head>
    <body>
    <c:url value="http://localhost:8080/tes2/coba2.jsp" var="displayURL">
      <c:param name="nama" value="saya"/>
    </c:url>
    <c:redirect url="${displayURL}"/>
    </body>
    </html>server2->coba2.jsp
    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
    <html>
    <head>
    <title>coba2</title>
    </head>
    <body>
    <c:forEach items="${param}" var="currentParam">
            <li><c:out value="${currentParam.key}" />
                = <c:out value="${currentParam.value}" /></li>
          </c:forEach>
    </body>
    </html>

    There are other two way communications methods as well. One such would be:
    Server1Page1: Take response with parameters.  Use HttpURLConnection to make a request to DataInputServlet
                  on Server2 and send the parameters there with a POST operation
    Server2DataInputServer: Takes request with data in it and starts a new session.  Puts the data into the session and
                  returns the session id to the requester
    Server1Page1: Reads the response from the DataInputServer (the session id) and generates a sendRedirect to
                  Server2's display page using the session id.  Server1Page1 is now done.
    Server2Page1: Gets a request from the client with the session id, and pulls the parameters out of the session.  Then
                  can continue as normal.Server2Page1 can also do a quick refresh to itself not using the session id as well, which will keep the URL visible by the client relatively clean.

  • Data Merge (ID) then Split Documents with Filename

    Hey everyone,
    I'm using InDesign and Data Merge to create business cards for our printer, but we of course have the recepients proof them first.
    I was wondering if there was a way where after the Data Merge, I could separate every 2 pages into their own PDF (front and back of card).
    Even more awesome would be if the PDF filename could be "<<FirstName>><<LastName>>-BC-proof.pdf"
    Thanks!

    Created this desription for someone looking to help, may clarify:
    So here’s my workflow and goal result for these files.
    I am creating special business cards for a handful of people in our company. And since our print vendor usually handles proofs and approvals per individual, I’ve got to try and replicate that process for this piece.
    I created an InDesign file with the fields I need to populate from a spreadsheet with all their contact information.
    Data Merge works like it should, and my merged document contains the front and back of each card for each individual in the handful of people. But now, I need to send out a copy of each for the recipient to approve.
    Another helper here has been manually splitting the documents and sending them out for approval, but I’d very much like to streamline the process (from merge, to proof, to approval, to printer). And the printer will likely be needing these in separate files for shipping reasons.
    So now that I have a merged document, my goal would be to export every 2 pages with a filename of the “<<LastName>><<FirstName>>-COE_BC_PROOF.pdf” so our helper can get them sent out for approval.
    A second step may be to re-do this process with bleed for the printers (or if that seems too much, the proofs will just include bleed and what not so we can forward them straight to the printer).
    So wadda ya think?

Maybe you are looking for

  • What is the correct replacement optical drive for MBP late 2007?

    Hello all, I am finally getting around to replacing my failed SuperDrive, a Panasonic UJ-857E. Reputable online resellers say the Panasonic UJ-867A will work.  I bought one.  It will not work, because the ribbon cable connector is a different shape t

  • Help needed in data type casting

    I have a java program which will receive data and its type in the String format. During program execution, the data in the String data has to be converted into the respective data type and assigned to a variable of that data type so that it could be

  • New to Web Services and BPEL - new hands-on introduction available

    If you are new to publishing business logic as a web services, or new to orchestrating web services as BPEL services, then this hands-on will give you a great introduction in taking your fist steps in the SOA world. The hands-on script is available h

  • Where is the battery indicator in itunes?

    subject says it all really. Isn't there supposed to be a battery indicator nest to the shuffle when it's connected to itunes? This is about a friends shuffle, but I know that when i used to connect my nano or now that i have an iphone, there is alway

  • PL/SQL XML Parser demo

    i've downloaded the Pl/SQL XML parser demo - xslsample / domsample - followed the guide , etc but I'm getting .... BEGIN xslsample ('/export/home/oracle/plmx/sample','family.xml','iden.xsl','family.out','errors.txt'); END; ERROR at line 1: ORA-29516: