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.

Similar Messages

  • Android, default install location does not have any effect

    I have Just5 Spacer 2 phone running Android 4.4.2 and since I can not root it (the only application I found was supposed to support it was SRS Root, but I only managed to get partial root through it) I thought I'd at least be able to set default install location for applications to external storage, but apparently, despite the fact that adb shows those changes I made, phone continues to install to internal storage.
    [dainis@arch platform-tools]$ ./adb shell pm set-install-location 2
    [dainis@arch platform-tools]$ ./adb shell pm get-install-location
    2[external]
    Any suggestions?

    By digging deeper and deeper I found a few posts/pages somewhere (didn't save sources for some reason) mentioning that this stopped working somewhere at around Gingerbread.
    Those who know - is that true?

  • Using a dll function that does not have any inputs from a VI

    Hello all, I'm very new to Labview, I have wraped a dll library using the LVlib wizard and now I am trying to use it in a project.  I have a function that does not take any inputs or return any thing except that a struct is populated with some status information as part of the call.  I am able to draw a StartInterface VI because my void startInterface(const char* configFile, struct status_struct* status) takes the location of a configutation file as an input. But I can not figure out how to connect my Call Library Node to my a function vi that does not have any inputs ( void shutdownInterface(struct status_struct* status)). 
    Note that the status struct is deffined to be only and out put at the creation of the LVLIB.
    Thanks, Mike

    Thanks for the responses guys:
       I think I am aware of the conotations of inputs and outputs when I created the lvlib I specified the argument  struct status_struct* status as only an output instead of the default of input and output.
    I do not think that I am doing anything as complex as function callbacks. My immediate goal is to have an executable (I have application builder) with two buttons and two three text fields one text field for the input of the config file, two text-fields for a cstring that is contained in the status struct; one button to start the interface and one button to stop the interface. 
    This is in all likely hood a case of my self being too dense and missing something fundimental ;-)  I just can't figure out how to wire the shut down method after I've configured the call library node. See the attached pictures:
    Attachments:
    Start.jpg ‏7 KB
    shurtdown.png ‏9 KB

  • Extending view object which does not have any entity object associated with

    Dear all
    I am interested in extended on of the standard pages VO object in JDeveloper OA extension
    the standard page is oracle/apps/pos/supplier/....suppSummaryPG
    and one of the view which I am interested to extend is suppSummVO
    the problem is that when I copy xml files and java files from apps server to
    my local jdevelope folder , I am not able to open that suppSummVO, the changes which
    I find from other VO object and this(suppSummVO) object is that, this VO does not have any
    Entity Object associated with it and the only query is return on this VO , is it the reason that
    I am not able to open it Jdeveloper, but the real issue is that how can I extends this type of VO
    in my OAExtension.
    Regard
    Noman

    Its the same way of extending VO with EO's or without EO's.
    Sometimes if the .class files arn't decompiled we get weird jbo errors. So use cavaj/jad to decompile those Impl.class, RowImpl.class files and keep them in the same folder as vo.xml in myprojects and try extending that VO.
    Thanks,
    Ravi

  • How to find a customer who does not have any activity in the last 5 years

    HI all,
       How to find a customer who does not have any activity in the last 5 years.
    Thanks & Regards,
    Moderator message: not directly related to ABAP development, please have a look in the respective functional forum.
    Edited by: Thomas Zloch on Jan 3, 2011 2:20 PM

    Post Author: tzinser
    CA Forum: Formula
    Okay, I left off a lot of important information...
    I'm using two tables
    TWDATA
    EVENT
    From TWDATA I'm pulling the fields TWDATA.OrderNumber and TWDATA.DisbursementDate
    From EVENT I'm pulling the fields EVENT.EventCode and EVENT.CompletedDate
    The two tables are linked by OrderNumber.

  • I cannot run iPhoto after update to Yosemite.  I cannot update iPhoto because the application store does not have any iPhoto update available.  Anyone can advice how to overcome this hassle?

    After update to Yosemite 10.10.3 the iPhoto program icon is banned and there is an error message that an update is required to run iPhoto, but the application store shows a message that iPhoto does not have any update available at this time.  There is not even any iPhoto program available on the application store.  Any suggestion on how to solve this annoyance?

    mende1 wrote:
    Unfortunately, Apple has removed both iPhoto and Aperture from the Mac App Store so they cannot be downloaded anymore. This means you are forced to migrate to Photos (included in OS X 10.10.3) or, if this app does not include features you need, look for a different app.
    Not true. Apple has removed both Apps from App Store so you cannot buy them anymore. But if you have any of these Apps already purchased in the past, then you can still download them on your Mac.
    Aristotle247 wrote:
    After update to Yosemite 10.10.3 the iPhoto program icon is banned and there is an error message that an update is required to run iPhoto, but the application store shows a message that iPhoto does not have any update available at this time.  There is not even any iPhoto program available on the application store.  Any suggestion on how to solve this annoyance?
    Open App Store, sign in with your Apple ID and go to Purchases tab. If you see iPhoto app listed there close down the App Store and do this steps as this is what worked for me:
    Open Finder and go to Applications folder.
    Locate iPhoto app
    Drag iPhoto app from your Applications folder to Trash (NOTE: Do not emptied Trash yet)
    Open App Store app and navigate to Purchases tab.
    Click on Install button which is next to the iPhoto app (on the right hand side).
    Once iPhoto is downloaded again, test it if its working for you. If all is ok, you can remove your Trash.

  • HT203167 My iTunes library on laptop is correct/up to date with recent purchases and downloads; however, our desktop computer does not have any of these when logged into Itunes.... how do I add these so both computers have current info?

    The iTunes library on our laptop is correct and up to date with recent purchases and downloads; however, our desktop does not have any of these when using it.  Home sharing is turned "ON" with both computers. Why is the desktop not showing the same content and how do I resolve this?

    From your OLD computer...
    Copy your ENTIRE iTunes FOLDER to an External Drive... and then from the External Drive to your New Computer..
    Full Details Here  >  http://support.apple.com/kb/HT1751
    Also see this migrate iTunes library post by turingtest2

  • Terminal server does not have any installed licenses

    Good morning! Faced with a some trouble while configuring Terminal Server (Windows Server 2012 based). I selected licensing mode "Per User" and now I see this message:
    “The Remote Desktop Session Host server is in Per User licensing mode and No Redirector Mode, but license server “server name” does not have any installed licenses with the following attributes:
    Product version: Windows Server 2008 or Windows Server 2008 R2
    Licensing mode: Per User
    License type: RDS CALs”
    So this is trial using of terminal server - I have 25 days yet but already today I can't connect to server using RDP. There is an error message about absent licensing server. How can I activate licenses in trial mode? Thank you for support.

    Hi,
    Thank you for posting in Windows Server Forum.
    From the error description it seems that your issue caused by setting up different Licensing mode. We need to install the proper RDS CAL on the License server.  If the license server has installed licenses of the other mode, changing the licensing mode
    for the terminal server may also resolve the issue. 
    To change the Licensing mode we can use RD Licensing diagnoser or by PowerShell command. 
    To change the licensing mode on RDSH/RDVH:
    $obj = gwmi -namespace "Root/CIMV2/TerminalServices" Win32_TerminalServiceSetting
    $obj.ChangeMode(value) - Value can be 2 - per Device, 4 - Per user
    Please refer below article for information.
    RD Licensing Configuration on Windows Server 2012
    http://blogs.technet.com/b/askperf/archive/2013/09/20/rd-licensing-configuration-on-windows-server-2012.aspx
    Have you installed License server on Server 2012 and you have RDS CAL of Server 2008 R2?
    If that’s the case then first you need to purchase the RDS CAL for server 2012 and then you can configure on server 2012 because server 2012\R2 RDS CAL can work with lower version OS but Server 2008 R2 RDS CAL can’t work on Server 2012\R2.
    Please check computability matrix.
    RDS and TS CAL Interoperability Matrix
    http://social.technet.microsoft.com/wiki/contents/articles/14988.rds-and-ts-cal-interoperability-matrix.aspx
    Hope it helps!
    Thanks.
    Dharmesh Solanki

  • Error : Rowkey does not have any primary key attributes

    Hello All,
    I'm developing an ADF application which has a few ADF forms. The forms have VO's and some tables.
    On running, I seem to be getting this error
    <Error> <oracle.adfinternal.view.faces.model.binding.CurrencyRowKeySet> <BEA-000000> <ADFv: Rowkey does not have any primary key attributes. Rowkey: oracle.jbo.Key[], table: oracle.jbo.server.ViewObjectImpl@2ecf4f19.>
    Where does the Rowkey have to be set? Is it in the VO?
    Regards,
    PP

    Make sure that the VO's you use have at least one attribute selected as a key attribute. GO to View Object overview editor and select attributes tab, see whether there is at least one attribute marked as a key. If not select the most appropriate attribute from the list of fields and go to edit attribute dialog, tick the key attribute property.

  • WSDL for WSDL based Proxy that does not have any input

    Hi all,
    I am trying to create a service which is based on a db adapter. The db adapter is created using a procecure that does not accept any input and gives out a cursor. I have created a
    proxy based on a wsdl which was created by me. I have not given any soap:body in the input as I dont have any input for this service. When I test the service it is not going into the
    request pipeline instead what ever the input (Here input in the sense even the proxy does not have any input as per the wsdl we need to give some xml tag to test it right?)
    to the proxy service is getting echoed back. It is neither going inside the request pipline nor Invoking the business service. When I create a proxy service as a plain xml then It is
    working fine. I am very confused and donno what to do.. Kindly help me on this.
    thanks
    Edited by: 887737 on Apr 5, 2012 4:20 AM
    Edited by: 887737 on Apr 5, 2012 4:21 AM

    it depends on the selection algorithm you have on the proxyservce
    on the fourth tab you can dispatch based on soapaction/body/header/etc
    you could dispatch on the soapaction and skip the body

  • Zcso_Doc_Proce_services====CCDFE does not have any Inactive   versions

    If copy the class form standard Class To Zclass  it comes the Error….
    when Check and Acivity this error come's
    Zcso_Doc_Proce_services====CCDFE does not have any Inactive   versions

    Dear shaik arief,
    1)Copy all related objects of the class to Zclass.
    2) Activate all although gives error.
    3)go to se80 -->Right click on class -> Check the syntax
    Probably this will solves the problem
    Regards
    Bhupal Reddy

  • Cannot modify application: [dimension] does not have any members

    Hi experts,
    When I try to add a newly created dimension to an application, I get the error message: "[dimension] does not have any members. Validate and process members first".
    I have indeed added members to the dimension and saved to the server and processed. However, I guess that the processing does not work as it should because when I process the dimension, it only goes further than "Progress (1/4)", followed by the message "The task has been successfully completed".
    I would expect it to go up to "Progress (4/4)....
    The backward compatibility pack has been installed.
    Any suggestions?

    Hi Petar,
    - Version is 7 SP4 for Microsoft
    - It's a customer install
    - Same behavior in Apshell. I can "process" the dimension in Apshell but I don't think it really processes it. It still stops at step 1/4 even at Apshell
    - When I add the dimension to an application, it says that the dimension does not contain any members, even in ApShell.
    So to summarize: the behavior is the same in Apshell.
    Can I look into any logs to see exactly what happens?
    Thanks,
    Sam

  • Trying to access row values in a table which does not have any rows yet

    try{
                             MappedRecord importParams = recordFactory.createMappedRecord("CONTAINER_OF_IMPORT_PARAMS");
                             IFunction function1 = client.getFunctionsMetaData().getFunction(funModGetDet);
                             IStructureFactory strucFact = interaction.retrieveStructureFactory();
                             response.write("try2 :"+pnumber);
                            IRecord structure = (IRecord) strucFact.getStructure(function1.getParameter("PERNR_TAB").getStructure());
                             response.write("try111 :"+pnumber);
                             structure.setString("PERNR",pnumber);
    I am getting the following error "Trying to access row values in a table which does not have any rows yet " where PERNR_TAB is a table containing field "PERNR".
    Can anybody help me out?

    Please re-post this question in the appropriate forum. It seems to have nothing to do with Web Dynpro.

  • Why Math class does not have any constructor.

    Math class does not have any constructor.
    But all the classes have a default constructor. Then why the math class is not having any constructor. Is math class having some other constructor or is the default constructor concept applicable only for user defined classes.

    Math class does not have any constructor.
    But all the classes have a default constructor. Then
    why the math class is not having any constructor. Is
    math class having some other constructor or is the
    default constructor concept applicable only for user
    defined classes.You cannot instantiate a new Math object, nor can you extend the Math class. All you can do is use Math's static methods and variables. Its a utility class, thats what its susposed to do.
    JJ

  • Query i need  Chart of account name It does not have any transactions.

    hi.
    i need a small query..
    As per my Requirement..
    Normally we are creating chart of account..
    Each account May or may not have transactions
    like Journal Entries we can pass debit and credit..
    I want to put in query generator if i run the query..
    It will shows the Chart of accounts names
    it does not have any transactions..
    Plz update me..
    If u doesn't  not  understood plz inform me..

    Hi,
    Pls Check this query.
    It will give the accounts which do not have entry in Journal Entry
    SELECT ACCTCODE, ACCTNAME FROM OACT WHERE ACCTCODE NOT IN (
    SELECT DISTINCT ACCOUNT FROM JDT1
    Regards,
    Amrut Sabnis.

Maybe you are looking for

  • Computer Crashed...How do I get my purchased applications back?

    My hard drive recently crashed. After getting everything I could back up and running, I connected my Touch to Itunes and it removed all my apps and saved info from my Touch. Where did they go? ITunes doesn't show my apps in the apps folder either alt

  • Port forwarding - Macbook not showing up in computer field

    I'm trying to forward a port in my d-link control panel. I have to select which computer on the network to do so...there are two pc's, one desktop, one laptop & then my Mac. They are both showing in the drop down box, my Macbook is not. I'm connected

  • Rearranging application using iTunes is very slow

    I was trying to rearrange my applications on my iPhone using iTunes and everytime I dragged and dropped an application to a new spot iTunes got stuck and the pinwheel of death appeared.  I would say that after each drop iTunes became unresponsive for

  • Error while Backup

    Hi Experts, When i try to take backup via. i'm getting this error :( . Pls Help C:\oracle\product\10.2.0\db_3\BIN>rman target / Recovery Manager: Release 10.2.0.1.0 - Production on Fri Nov 9 22:30:33 2012 Copyright (c) 1982, 2005, Oracle.  All rights

  • Loyalty points are stored in which entity?

    Hi, I need to integrate Siebel's loyalty management with ATG and for That I need to know What is the data that flows from Siebel to ATG for loyalty functionality. So I need to know below things- In which entity loyalty/reward points are stored in Sie