Why do we want ImageDateSource ? I went trough IDS class and found that using that you can not even get image so I can not understand why we use IDS . If we are going to have IDS e we have to add a convenient API to IDS to get image directly out of that rather than getting out/in stream while we are fixing errors in that.
Thilina Gunarathne wrote: > At first look seems there's a problem with the image utility > classes.. It's better to use the FileDataSource in any case, since > it's the most generic one and it'll make sure to send what ever the > bytes in your original file... > > ~Thilina > > On 5/10/06, *Patric Fornasier* <[EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]>> wrote: > > Hi, > > I've found the problem. > > First of all, I didn't explicitly set the content type to "image/png" > which explained the additional size, as jpeg headers were added: > > DataSource ds = new ImageDataSource(" image.png", "image/png", image); > > Then however I had the problem that the received file size was > smaller! > I compared the binaries and realized that some meta data was stripped > out. In some cases you might not care, but I think this can be quite > dangerous. I then used a FileDataSource instead of a ImageDataSource, > which solved the issues and now both files are exactly the same. > > Server: > DataSource ds = new FileDataSource(file); > DataHandler dh = new DataHandler(ds); > OMText textData = factory.createOMText(dh, true); > > Client: > DataHandler dh = (DataHandler) out.getDataHandler(); > InputStream is = dh.getDataSource().getInputStream(); > OutputStream os = new FileOutputStream("c:/dynamic- axis.png"); > > Anybody came across similar issues? > > Cheerio, > patric > > -----Original Message----- > From: Patric Fornasier > Sent: Thursday, 11 May 2006 2:06 PM > To: [email protected] <mailto:[email protected]> > Subject: Loosing bytes with MTOM > > > Hi, > > I'm sending a small png image from one server to another via MTOM. The > service and the client are both on the same machine. > > The original size of the image is 6450 bytes. When the clients copies > the file to the file system however, the size of this copy is now > 15083 > bytes! > > Funny enough, the received picture looks fine. It's just roughly 3 > times > bigger. > > Anybody got an idea what's going on here? > > Here's the code for the server: > --- > Image image = new ImageIO().loadImage(new FileInputStream(file)); > DataSource dataSource = new ImageDataSource("image.png", image); > DataHandler dataHandler = new DataHandler(dataSource); // create an > optimized OMText node with the above DataHandler OMText textData = > factory.createOMText(dataHandler, true); out.addChild(textData); > > And for the client: > --- > OMText out = (OMText) response.getFirstOMChild (); > > DataHandler actualDH = (DataHandler) out.getDataHandler(); ImageIO > io = > new ImageIO(); Image img = > io.loadImage(actualDH.getDataSource().getInputStream()); > FileOutputStream imageOutStream = new > FileOutputStream("c:/dynamic- axis.png"); > io.saveImage("image/png", img, imageOutStream); > > Any hints are greatly appreciated! > > Cheers, > patric > > ------------------------------------------------------------------------ > > -- > This email and any attachments may be confidential. They may contain > legally privileged information or copyright material. You should not > read, copy, use or disclose them without authorisation. If you are > not > an intended recipient, please contact us at once by return email and > then delete both messages. We do not accept liability in > connection with > computer virus, data corruption, delay, interruption, unauthorised > access or unauthorised amendment. This notice should not be removed. > > > > > -- > "May the SourcE be with u" > http://webservices.apache.org/~thilina/ > <http://webservices.apache.org/%7Ethilina/> > http://thilinag.blogspot.com/ > http://www.bloglines.com/blog/Thilina -- Thanks, Deepal ................................................................ ~Future is Open~
