Image reading problem

hi,
i'm reading a gif image from an input stream like this:
InputStream input = document.getBlobProperty(property).getInputStream();
          byte[] theBytesTemp = new byte[1048576];
          int length = input.read(theBytesTemp);
          byte[] theBytes = new byte[length];
          System.arraycopy(theBytesTemp, 0, theBytes, 0, length);
          BufferedImage originalImage = new ImageParsing().getBufferedImage(theBytes);
          input.close();
(the document.getBlobProperty(property).getInputStream();) is provided by the CMS we use and just returns an input stream. my problem is that the BufferedImage originalImage = new ImageParsing().getBufferedImage(theBytes); (that's part of the sanselan imaging library) throws an exception (java.io.IOException: GIF: corrupt block) for larger images (not sure about the size in detail. images about 10K seem to work, images of about 50K don't).
Any ideas?
Marco

Hello, Im having the same problem, but im getting the data from a database, and try to output via JSP and getting a currupted image,
How can i implement this code database binary data, since i cant get the data into input stream.
eg:
* how to copy data in the data field as byte[] to the InputStream,
* how to use ImageParsing().getBufferedImage(imageBytes); which i can't able to find the class for it,
     ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
     int bufferLength = 1024*1024;
     byte[] buffer = new byte[bufferLength];
     int length = 0;
     /* Im having problem of getting the data to the input stream on below line */
     InputStream input = af.getImg();
     while ((length = input.read(buffer)) != -1) {
          byteArrayOut.write(buffer, 0, length);
     input.close();
     byteArrayOut.close(); //Has no real effect
     byte[] imageBytes = byteArrayOut.toByteArray();
     /* cant find the class for ImageParsing() */     BufferedImage originalImage = new ImageParsing().getBufferedImage(imageBytes);
     OutputStream out = response.getOutputStream();
     /* cant write BufferedImage to the out put stream */     out.write( imageBytes );
     response.flushBuffer();          You shouldn't try to read all the bytes at one time
like that, there are no quarantees that the read
opperation will fill the array or read all the bytes
in the inut stream (this the need to return the
length read).
Instead, put the read into a loop, reading into a
buffer, then append the buffer onto a byte array
output stream...
ByteArrayOutputStream byteArrayOut = new
ByteArrayOutputStream();
int bufferLength = 1024*1024;
byte[] buffer = new byte[bufferLength];
int length = 0;
InputStream input = ...
while ((length = input.read(buffer) != -1)
byteArrayOut.write(buffer, 0, length);
input.close();
byteArrayOut.close(); //Has no real effect
byte[] imageBytes = byteArrayOut.toByteArray();
BufferedImage originalImage = new
ImageParsing().getBufferedImage(imageBytes);

Similar Messages

  • Image reading problem in servlet

    Image reading problem in servlet
    I am reading an image in servlet and writing it to ServletOutputStream
    The following code works fine unless I change the size of the byte array (for increasing download speed) from 8 to something like 128 or any other higher value
    If I change the value of byte array size the image does not get downloaded properly, I mean the quality of the image changes, it does not looks like the original imageURL url = new URL("http://www.mysite.com/images/img1.jpg");
    URLConnection con = url.openConnection();
    con.setUseCaches(false);
    BufferedInputStream in = new BufferedInputStream(con.getInputStream());
    BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream());
    byte b[] = new byte[8];
    while(in.read(b) != -1)
         out.write(b);
         out.flush();               
    out.close();
    in.close();what do I change
    byte array size
    or use the constructor of BufferedInputStream with 2 parameter
    or use the constructor of BufferedOutputStream with 2 parameter
    or use flush outside while loop or what else

    Change your while loop to:
    int count;
    while((count = in.read(b)) != -1)
         out.write(b, 0, count);
         out.flush();               
    }The penultimate time read is called, it may not fill the entire byte array. You only want to write out however much was read into the array.
    For better performance, you should move the flush() outside of the loop too. BufferedOutputStream will flush automatically when its internal buffer is full.

  • I have LR5 on a mac book pro with a external hard drive with LR5 images. my problem is my external hard corrupted reformatedand have to this is expensive and i would to start over in LR5

    i have LR5 on a mac book pro with a WD external hard drive with my with my LR5 images . my problem is my external drive is corrupted .i was told by apple that my macshow the hard drive is there but it is not moumting and have to be reformat. i have to use recovery data to save my images on my external before i can refomat.iam willing to lose my images on my extenal hard drive but i would like to know can i erase my LR5 images and start over or delete LR5 and download it again

    Simply start a new catalog:
    File >> New Catalog
    Choose a new name and save.
    When the empty catalog launches you are ready to start over.

  • My iMac 27" Late 2012 has Image Persistence Problem

    I'm wondering what to do about an annoying image persistence problem on my 27" late 2012 iMac. I got the iMac just a few days ago. Monday actually, so 4 days ago.
    It's the 3.4GHz i7, 8GB, NVIDIA 680MX 1TB fusion drive model.
    Overall it has become the love of my life, but the image persistence thing is getting harder to ignore. This happens after only a few minutes of use. If I follow Apple's instruction on dealing with LCD image persistence, I can make it go away for a while, but it comes back very quickly.
    It is extremely noticeable on a plan dark background. It looks as thought he screen has been left on for a very long time with the same windows open, but it occurrs in less than 5 minutes of use with nothing more intense than a bit of web surfing.
    I've read that this is happening a great deal on these new iMacs, particularly teh 27" machines.
    While the problem seems to be known to those of us afflicted I don't know if Apple has acknowledged an issue or not.
    Here is a sample of the complaints: http://forums.macrumors.com/showthread.php?t=1509571
    I can make the ghost image vanish by bringing up an all white scree for a minute or so or using LCD Scrub.
    I'm wondering if anyone else has foun a solution other than asking for a replacement computer, which Apple seems to be granting on this issue?

    Avoiding image persistence on Apple (IPS) displays
    Avoiding image persistence on Apple LCD displays
    If you cannot resolve the issue yourself, then return the computer for a replacement. You may do this freely within 14 days from date of purchase, so don't delay.

  • Having a image alignment problem using clearbox

    Hi,
    I'm having an image alignment problem. I cannot figure it out. I'm using the clearbox - lightbox dreamweaver widget. Using Dreamweaver CS6.
    Actual page located here. Any help would be appreciated.
    http://dirtysouthink.com/gallery/dustin2.html

    This has very little to do with Dreamweaver. DW is merely a tool to assist you in building a web site. It is purely a matter of styling (CSS).
    When I look at the structure, I see
    BODY-CONTENT (width: 490px)
         GALLERY (width: 452px)
              CONTAINER (width: 500px)
                   ITEM (width: 150px)
    From this I can deduce that:
    GALLERY will fit inside BODY-CONTENT
    CONTAINER will NOT fit inside GALLERY or BODY-CONTENT
    ITEM will fit three times into CONTAINER
    To start with, I would reduce the size of the CONTAINER so that it fits inside of its parent. Then I would adjust the width of the ITEM so that only two of them fit inside of the CONTAINER.

  • How to solve the image display problem in the iTunes Store

    Hi guys!
    I just want to give a work-around for all of you having the image display problem in the iTunes Store. In my case only the square images in the slider sections won't load:
    I had this in my last W7-installation and got it again in W8 after the first few weeks.
    There are a lot of reports about this problem out there and adhoc solutions like 'clear the cache' or 'reinstall and drink ice tea' that do not work. It is obviously a file request error. It is all about finding out which server addresses get blocked by your computer.
    Solution: Go to your firewall and your Anti-virus-program. There must be a whitelist option. In Kaspersky, check the web-options, the banner-options and the firewall-options, because the all have whitelists. The following addresses have to be whitelisted:
    *.apple
    *.mzstatic.apple.com.akadns.net
    *.mzstatic.com.edgesuite.net
    *.da1.akamai.net
    *.itunes.apple.com
    se.itunes.apple.com
    upp.itunes.apple.com
    ax.init.itunes.apple.com
    xp.apple.com
    *.mzstatic.com
    client-api.itunes.apple.com
    www.apple.com.edgekey.net
    www.isg-apple.com.akadns.net
    Press Ctrl + R in the iTunes Shop then and browse throught the music sections. All images should be displayed correctly now.
    If not, there might be more Apple servers involved in your case. You can find them by running a DNS sniffing tool like the DNS query sniffer by Nirsoft or Wireshark.

    Phone restarting randomly could be loose battery. Tighten by putting a small strip of electrical tape on the back edge.
    THE BITTERNESS OF POOR QUALITY, LINGERS LONG AFTER THE CHEAPNESS OF PRICE, IS SOON FORGOTTEN.

  • Image Serializable problem.

    Hi,
    I have provided a hacked down version of my source code. I am trying to send ClassA across the network. Problem is Image is not serializable so java.io.NotSerializableException is thrown when writeObject is called. How can I get around it?
    public ClassA implements Serilizable{
    Image img;
    public ClassA(Image img){
    this.img = img;
    public ClassB{
    public void send(){
    out = new ObjectOutputStream(clientSocket.getOutputStream());
    out.writeObject(classAInstance);
    }

    is this Image from the swing package? if so, use ImageIcon instead of Image.

  • Netinstall image  installation problem

    Hi, I'm new in MacOSX Server and trying to do image file with System Image Utility 10.6.2 - MacOS10.6 and additional packeges (MacOSXUpdCombo10.6.2, iWork'09, iLife'09) with "AddPackages and Post-Install Script". By making a image no problem but when I start the installation occurs the following problem.
    MacOs10.6 install correct but other programs added in "AddPackages and Post-Install Script" is not installed, and in Macintosh HD is created a folder named Install.76443 with locked directories.
    Where is the problem why the additional packages not installed.
    My SIU configuration is :
    Define Image Source: MacOSXInstallDVD
    Add Packages and Post-Install Scripts
    - MacOsx10.6.2. Update Combo
    - iLife'09.pkg
    - iWork'09.pkg
    Create image
    type: Netinstall
    Install Volume: Macintosh HD
    Save to: Documents
    Image Name: Netinstall of Mac OS X Install DVD
    Network Disk: Netinstall of Mac OS X Install DVD
    Image Index: 1533
    Description: Netinstall of Mac OS X Install DVD
    i want to create one image for all packages and updates and install it from network to all computers in my office.
    thanks

    I think this is covered in a different thread but, in short, the 10.6.2 update will fail to install on top of the 10.6 DVD. YMMV with the iLife & iWork packages as they may run pre-install scripts that will also cause them to fail.

  • RH8 image map problem

    I created an image map back in RoboHelp 6 and it worked perfectly. When I converted my project recently to RoboHelp 8, the image map pop-ups are not working correctly. I've checked the properties of the image map and they are correct. But the pop-up boxes do not display correctly. I'm going to attached an example of how the same one displays in RH6 and RH8 and a screen shot of my settings.
    Can anyone help me with this?

    After much trial and error testing around this image map issue, I cannot seem to find a fix for image maps within RoboHelp 8. No matter what I've tried (and it was a lot), nothing seems to fix the image map problem. Even creating a new image map on a new page with totally different info, pop up pages, image, etc. and turning OFF all breadcrumbs - the image map does not display correctly once generated (nor in preview).
    I have found a VERY TEDIOUS workaround for this (that I'm not happy about). If I take my original pop-up topic htm pages (9 of them) from my RoboHelp 6 project and the original eHlpDhtm.js file from RH6 and place them in my output Help file from RH8 (overwriting the RH8 with the RH6 files), then the image map works correctly.
    The eHlpDhtm.js file has many more scripts in it than just the image map triggers, so I'm not sure what all else I'm affecting when I'm fixing one problem (i.e. not sure how many more problems I'm creating at the same time when fixing one problem.)
    It's almost like the "breadcrumbs" feature in RH8 has broken the image maps feature in RH8.
    I'm still up for more suggestions as how to fix this if anyone has any ideas.

  • How can I save the images and movies on a  external Disk from iphoto program, to protect the images when problems occur in the laptop,

    How can I save the images and movies on a  external Disk from iphoto program, to protect the images when problems occur in the laptop,

    Most Simple Back Up:
    Drag the iPhoto Library from your Pictures Folder to another Disk. This will make a copy on that disk.
    Slightly more complex: Use an app that will do incremental back ups. This is a very good way to work. The first time you run the back up the app will make a complete copy of the Library. Thereafter it will update the back up with the changes you have made. That makes subsequent back ups much faster. Many of these apps also have scheduling capabilities: So set it up and it will do the back up automatically.
    Example of such apps: Chronosync - but there are many others. Search on MacUpdate or the App Store
    If you want to back up the Photos only:
    Export them using the File -> Export command.
    This User Tip
    https://discussions.apple.com/docs/DOC-4921
    has details of the options in the Export dialogue.

  • Problem: codebase, jar and image reloading problem please help!

    Hi Java Gurus,
    I have written an applet that extends JApplet for viewing webcam. In order to reduce the download time I put my classes into a doorcam.jar file. The following is my <applet> tag in my html file.
    <applet code="CameraApplet.class"
    archive="doorcam.jar"
         codebase = "webcam/classes"
         width="375" height="475">
    <param name="imagePath" value="http://judge/webcam/images">
    <param name="webCamImage" value="door.jpg">
    <param name="COMPort" value="COM2">
    <param name="frameRate" value="10"> <!-- could not exceed more than 10-->
    <param name="host" value="judge">
    </applet>
    The fist problem is that my class file does not get loaded from the jar file if i provide the "codebase" attribute as above. Instead the browser load every single class file from the webserver. This has some problem too. Coz the browser sometimes just thorough NullPointerException or ClassNotFoundException. After much of debugging I found out that the problem is the IE browser which seldom fails to load classes or image file from the server. If i referesh the browser the applet and all its classes loaded successfully and runs smoothly. This behaviour never occurs when running with "appletviewer".
    I wanted all my classes to be loaded from my jar file. After much of trial and error I found out that if i remove "codebase" attribute the browser loads the classes from my jar file and applet loads very fast. This is where the second problem comes in. The browser does not reload my webcam image file so that the webcam become alive with live images, like before.
    If I run on "appletviewer" everything works fine my web cam is displayed properly. But in IE browser the image does not get reloaded when I refresh my image to give live to my webcam display. The refresh method is given below.
    private void refresh(final URL url) {
    Image webCamImage =getImage(url);
    webCamImage.flush(); // flush out the previous image
    webCamImage = getImage(url); // get a new image
    webCamImageIcon.setImage(webCamImage); webCamImageIcon.paintIcon(webCamLabel, webCamLabel.getGraphics(), 15, 15);
    When I add the "codebase" attribute back, the image gets reloaded for every refresh() and everything works fine. But the classes are also loaded from the server. And occasionally also suffers Class loading and image loading problem. As I presented earlier, when I do refreshing in the browser everything gets loaded and the applet function correctly with web cam displaying very well.
    The problem is so strange that I could not find any way to solve it.
    It would be a great help to me if somebody provide me some work around to the problem.
    I tested on Windows 2000, Windows XP, IE 5.5, IE 6 with J2SDK 1.4.0.
    Thank you all very much in advance.
    best regards,
    Judge

    Thank you so much for the suggestions. I did tried the way u suggested. The problem still the same.
    I think its the problem between IE browser and Java Plug-in.
    I which SUN would find these incompatibilities and solve these problems.
    I even tried using java SDK and plug-in 1.4.1 it even worst. It can't even load an applet. And it does not show any loading messages nor any error messages. It just show a cross sign on the upper left coner.
    I would be so glad, if Sun would try to eliminate the inconsistancies such as caching, loading, initializing etc between browser and its Java plug-In. For example, applets behave well in appletviewer and behave unpredictably in browser environment.
    I have seen so many people in the forums with all sorts of problems because of this.
    Right now I m desperately looking for work around to my problem.
    If somebody would provide me with the solution to my problem it would be a great help to me.
    thank you all so much.
    best regards,
    Judge

  • SSRS indicator image display problem!!

    Hello ALL;
    I am having problem with displaying indicator image in DEV report manager. but same rdl works in QA environment. Both server has SP1 installed. Any Idea? Appreciate for your help. Thanks,

    Hi Techchi,
    Based on the limited information, I cannot figure it out for this issue. As per my understanding, I think this issue can be caused by the browser that run the report manager. If you use IE explorer to render the report, I suggest that you can try to run
    it in compatibility mode. If you are using another browser, I recommend that you should use IE explorer to render the report to check the issue again.
    If this issue still exists, in order to solve the problem more efficiently, I need to clarify some information.
    Are all reports with indicator image cannot render well in DEV report manager? Or just this one report?
    What is the phenomenon about the indicator image display problem? Could you please post a screenshot about this?
    It is benefit for us to do further analysis. Thank you for your understanding.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • I cannot display image (read from oracle BLOB field) on browser?

    I cannot display image (read from oracle BLOB field) on browser?
    Following is my code, someone can give me an advise?
    content.htm:
    <html>
    <h1>this is a test .</h1>
    <hr>
    <img  src="showcontent.jsp">
    </html>showcontent.jsp:
    <%@ page import="com.stsc.util.*" %>
    <%@ include file="/html/base.jsp" %>
    <% 
         STDataSet data = new STDataSet();
    //get blob field from database     
         String sql = "SELECT NR FROM ZWTAB WHERE BZH='liqf004' AND ZJH='001'";
         //get the result from database
         ResultSet rs = data.getResult(sql,dbBase);
         if (rs!=null && rs.next()) {
              Blob myBlob = rs.getBlob("NR");
              response.setContentType("image/jpeg");//
              byte[] ba = myBlob.getBytes(1, (int)myBlob.length());
              response.getOutputStream().write(ba);
              response.getOutputStream().flush();
         // close your result set, statement
         data.close();     
    %>

    Don't use jsp for that, use servlet. because the jsp engine will send a blank lines to outPutStream corresponding to <%@ ...> tags and other contents included in your /html/base.jsp file before sending the image. The result will not be treated as a valid image by the browser.
    To test this, type directly showcontent.jsp on your browser, and view it source.
    regards

  • Iterate over selected images, read/change crop settings in LR3?

    Since there is a new SDK I thought I ask again for this version:
    I'd like to write a Lightroom script which iterates through all selected images, read and change the crop settings of (nearly) every image.
    Is this possible to achieve in lua using the LR3 SDK? Or is it still not possible to read and write development settings?
    Kind regards,
    Sam

    You can read individual develop settings but only apply presets. That's better than nothing, but allowing us to write develop settings would have opened up a whole new world of possibilities - I think it scared them...
    A possible work around: read settings, create a temp preset, write changed settings to the temp preset, then apply it.
    NoYeah?
    Rob

  • Image refresh problem

    hi, i have an image inside an iframe that i'm trying to
    change upon the click of a button. i use the following code:
    <SCRIPT language="JavaScript" type="text/javascript">
    function swapImage(intImage){
    var
    imgs=["images/pic0.jpg","images/pic1.jpg","images/pic2.jpg","images/pic3.jpg","images/pic 4.jpg",
    "images/pic5.jpg"];
    parent.frames['cont'].document.getElementById('mgmnt_pic').src =
    imgs[intImage];
    alert(parent.frames['cont'].document.getElementById('mgmnt_pic').src)
    </SCRIPT>
    then in body:
    <p><a href="javascript:; "
    onclick="frames['cont'].swapImage(0);">Management
    Team</a></p>
    i know from the alert that it is changing the source of my
    image, the problem is that the image itself is not changing at all.
    has anyone experienced this before? what can i do to fix it?

    Hi,
    chk the link
    http://javascript.internet.com/miscellaneous/random-image.html
    shanthi

Maybe you are looking for