How can I merge two TIFF images in one...?

I need some help please, I am looking for a way to "resize" black & white single TIFF images.
The process I need to do is like cutting a small image and paste it over a new blank letter-size image (at 300 dpi), like a template.
Or better yet, is there a way to do something like this...?
Open image...
image.*width* = 2550;
image.*height* = 3300;
image.save();Some APIs and topics in the internet do or talk about resizing, but the final images get stretched or shrinked and I need them not to do so at all.
Also, I do not need to display the images, only to get the TIFF images processed and saved back to a file.
How can I do this with Java and JAI? Unfortunately I am almost new to this and I don't know how difficult it might be to deal with images.

If 2550 x 3300 isn't the original aspect ratio of the image, then the image is going to looked streched or shrinked in at least one dimension. There is no way around that. It would be like resizing a 2 pixel by 2 pixel image into a 3 pixel by 6 pixel image. The image would look like it's height shrunk or it's width stretched. Had I resized it to 3 pixels by 3 pixels or 6 pixels by 6 pixels, though, then it wouldn't look shrunken or streched.
Open image...
image.*width* = 2550;
image.*height* = 3300;
image.save();*1)* To open a TIFF image you can use the javax.swing.ImageIO class. It has these static methods
read(File input)
read(ImageInputStream stream)
read(InputStream input)
read(URL input) You can use which ever method you want. But first you need to install [JAI-ImageIO|https://jai-imageio.dev.java.net/binary-builds.html]. The default ImageReaders that plug themselves into the ImageIO package are BMP, PNG, GIF, and JPEG. JAI-ImageIO will add TIFF, and a few other formats.
The downside is that if clients want to you use your program on their machine then they to will need to install JAI-ImageIO to read the tiffs. To get around this, you can go to your Java/jdk1.x.x_xx/jre/lib/ext/ folder and copy the jai_imageio.jar file (after you've installed JAI-ImageIO). You can also obtain this jar from any one of the zip files of the [daily builds|https://jai-imageio.dev.java.net/binary-builds.html#Daily_builds]. If you add this jar to your program's classpath and package it together with your program, then clients won't need to install JAI-ImageIO and you'll still be able to read TIFF's. The downside of simply adding the jar to the classpath is that you won't be able to take advantage of a natively accelerated JPEG reader that comes with installing JAI-ImageIO (instead, ImageIO will use the default one).
*2)* Once you've installed [JAI-ImageIO|https://jai-imageio.dev.java.net/binary-builds.html] and used ImageIO.read(...), you'll have a BufferedImage. To resize it you can do the following
BufferedImage newImage = new BufferedImage(2550,3300,BufferedImage.TYPE_BYTE_BINARY);
Graphics2D g = newImage.createGraphics();
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g.drawImage(oldImage,0,0,2550,3300,null);
g.dispose();Here, I simply drew the old image (the one returned by ImageIO.read(...)) onto a new BufferedImage object of the appropriate size. Because you said they were black and white TIFF's, I used BufferedImage.TYPE_BYTE_BINARY, which is a black and white image. If you decide to use one the BufferedImage types that support color, then a 2550x3330 image would require at least 25 megabytes to hold into memory. On the other hand, a binary image of that size will only take up about one meg.
I specified on the graphics object that I wanted Bilinear Interpolation when scaling. The default is Nearest Neighbor interpolation, which while fast, dosen't look very good. Bilinear offers pretty good results scaling both up or down at fast speeds. Bicubic interpolation is the next step up. If you find the resized image to be subpar, then come back and post. There are a couple of other ways to resize an image.
Note, however, if 2550 x 3300 is not the same aspect ratio as the the TIFF image you loaded, then the resized image will look shrunk or stretched along one dimension. There is absolutely no way around this no matter what resizing technique you use. You'll need an image whose original dimensions are in a 2550/3300 = .772 ratio if you want the resized image to not look like it's streched (you can crop the opened image if you want).
*3)* Now we save the "newImage" with the same class we read images with: ImageIO . It has these static methods
write(RenderedImage im, String formatName, File output)
write(RenderedImage im, String formatName, ImageOutputStream output)
write(RenderedImage im, String formatName, OutputStream output)You'll suply the resized BufferedImage as the first parameter, "tiff" as the second parameter and an appropriate output for the third parameter. It's pretty much a one line statement to read or write an image. All in all, the whole thing is about 7 lines of code. Not bad of all.
Now as for the 300 dpi thing, there is a way to set the dpi in the Image's metadata. I'm pretty good at reading an image's metadata, but I've never really tried writing out my own metadata. I know you can set the dpi, and I have a somewhat vague idea how it might be done, but it's not something I've tried before. I think I'll look more into it.

Similar Messages

  • Can you merge two still images into one in premiere elements?

    I am working on a slide show for a memorial service and would like to have one still image showing and then have the next one come in without replacing the former- somehow merge the two. Is that possible?

    Depending on what you mean by "merge," you can use PiP (Picture in Picture) to have the second image come in and occupy part of the screen with the original image. There are many ways to display PiP, from say a small image located in the screen to having it occupy one half of the screen.
    Does that sound like what you are hoping to do?
    Besides the rather simple PiP, one can also use Track Matte Keying to bring up the second image and to soften edges, drop it into an image of, say a TV set, or a window.
    The possibilities are endless, or nearly so.
    Let us know if PiP works for you, or if you need a more intricate merging of the images.
    Good luck,
    Hunt

  • I have an iPad 2 and a Nikon DSLR. How can I transfer RAW/Tiff images using a compact flash card

    I have an iPad 2 and a Nikon DSLR. How can I transfer RAW/Tiff images using a compact flash card? Plugging in the camera at the ipad connector doesn't seem to work, possibly due to lack of power.

    This may apply.
    Fix (for Nikon D800)
    http://www.georgewheelhouse.com/blog/2012/10/ipad-ios-6-update---camera-connecti on-kit-fix
    Are you using an SD, SDHC, or SDXC card? And what capacity?
     Vheers, Tom

  • HT204053 how can I merge two Apple-IDs?

    how can I merge two Apple-IDs?

    The Apple Support Communities are an international user to user technical support forum. As a man from Mexico, Spanish is my native tongue. I do not speak English very well, however, I do write in English with the aid of the Mac OS X spelling and grammar checks. I also live in a culture perhaps very very different from your own. When offering advice in the ASC, my comments are not meant to be anything more than helpful and certainly not to be taken as insults.
    Apple will not merge two Apple IDs, nor will Apple transfer content from one ID to another.
    http://support.apple.com/kb/HE37

  • How can I have two itunes accounts on one computer?

    How can I have two itunes accounts on one computer?

    Not sure what you mean.
    An account is a user name and password.
    Sign into whichever account you want to use for purchasing.
    Authorize the computer for both account to listen to the content.

  • How can I combine two itunes accounts into one?

    How can I combine two itunes accounts into one?

    Items purchased from the iTunes Store are permanently associated with the account from which they were originally purchased.  Apple provides no way to change this.
    However, if you wish to put content from two accounts into a single iTunes library, you can easily do so.  Use the command File > Add File (or Folder) to Library.

  • How can i sync two different ipods to one computer

    How can i sync two different ipods to one computer

    How to use multiple iPods, iPads, or iPhones with one computer

  • I have two cell phone, different numbers.  Each has their own apple id.  How can i merge them so apps on one show on the other but keep their emails addresses separate on their own phone?

    Have two cell phones, different numbers.  Each has their own apple id.  How can I merge them so apps purchased on one phone show on the other.  But.as each has their own email address, I want to keep these email addresses separate on their own phone?  Thanks.

    We do this in my family now.  We have one account for purchases, so it is used to share music and apps (I think that is in Settings/iTunes & App Stores).  Each iDevice has this configured.
    Then, each of us has our own iCloud account that is configured under Settings/iCloud.  That then allows us to have our own Mail/Contacts/Calendars/Reminders/Safari Bookmarks/Notes/Passbook/Photo Stream/Documents & Data/Find My iPhone/and Backup.  That Backup piece is pretty sweet and comes in handly if you replace your iDevice.  You can just restore from it.
    So we all share the Apple Store account but we all have our own iCloud accounts to keep the rest seperate or things like you mentioned are a nightmare.
    In answer to what iCloud does for you: http://www.apple.com/icloud/features/
    Think of it as an internet based ("cloud") area for all of those items listed in my response.  What you need to remember is photo stream only maintans the last 1000 pictures so don't count it as a complete backup solution for your pictures.  Even though I rarely sync with a computer these days, I do still try to sync my phone with iPhoto (I have an iMac) so that I have copies of all of my pictures.  1000 may not stretch as far as it sounds.
    Message was edited by: Michael Pardee

  • HT1918 how can I merge two itune accounts?

    I had an account for itunes and, not thinking, created another one tonight, so I have music under both accounts.  How can I merge the two?

    Sorry - you can't. You can keep the music from each iTunes account in the same library, but the purchased items will always be "owned" by the iTunes ID under which they are purchased.
    My husband and I both purchase music and other stuff on his Mac in iTunes under our own iTunes IDs. Both IDs are authorized to the Mac, and everything is housed in one iTunes library. I can download his music, and he can download mine.
    However, if, say, some of the music was removed from the library and we wanted to get it back in there, we would each individually have to go to our Purchased list to download the items that we purchased in order to get them all back into the library.
    Hope that explanation helps!
    Cheers,
    GB

  • How do i merge two pdf files into one

    How do i merge 2 pdf files into one.

    Open up the first pdf in Preview
    Then from Menu
    select from Edit Menu
    Select Insert (your choice of)
              Page from Scanner
              Page from File (select your PDF file)
              Blank Page
    You can then save as your first file or rename it

  • How can I merge my iCloud accounts into one account without losing data?

    How can I merge my mistake iCloud accounts into one account without losing all my info?

    You cannot merge accounts
    iCloud Support
    http://www.apple.com/support/icloud/

  • HT204053 Can you merge two Apple IDs into one?  It was a common issue caused by the iPhone 4 and has been corrected, but transferring purchases in iTunes is a pain with two IDs.

    For a brief time when iPhone 4, iOS 4 came out, many of us ended up with two Apple IDs.  I want to know if anyone can please provide me with simple step-by-step instructions on merging two Apple IDs into one?  It would make transferring purchases on iTunes much easier and reliable.  I realize i desperately need an iOS update, but i had no laptop for over two years!  I'm posting a cry for help on that in another community.  Thank you all.

    No,
    Apple IDs cannot be merged. You should use your preferred Apple ID from now on, but you can still access your purchased items such as music, movies, or software using your other Apple IDs.

  • Can i merge two apple ids into one

    i have two apple IDs that i need to merge.  money is both accouts, paid apps on both accounts.
    What are my options?
    thanks

    http://appletoolbox.com/2012/10/can-i-merge-two-or-more-apple-ids-using-multiple -apple-ids/
     Cheers, Tom

  • How can i write two ?DDL in one query

    how can i write two ?DDL statment in one query?

    Issuing two DDL statements requires two edxecutions. Getting around it is possible by creating a procedure that issues the two DDL statements. But they would still have to be issues one at a time, but you would only have to write one statement to invoke it.

  • How can I use two differant iphones on one itunes

    I can i use two differant iphones on one itunes, and keep the content seperate?

    You can sync as many iphones/ipod/ipads as you like to one computer.
    Each is different and is recognized as such

Maybe you are looking for