1 2 Previous Next 51 Replies Latest reply on Dec 24, 2014 1:45 PM by Mr Papajohn

    What causes 'Unexpected end-of-file' error?



      I am a photographer and an avid Lightroom user. I have two camera's (Nikon D700 and D300) and two computers, a desktop PC and a MacbookPro. Lightroom is installed on both computers.


      For the last three photoshoots I have had this problem where 1 in 3 to 1 in 5 images in Lightroom on my desktop PC suddenly gives a 'Unexpected end-of-file' error. First I thought it was my camera. But then I loaded the images onto my MacbookPro and they worked fine. Then I took some images with my other camera, loaded them on to my Desktop PC, and, voila, same problem.


      The problem specified: the image stops rendering a preview. A dull preview appears. At the top of the screen the message appears: "An unexpected end-of-file occurred." The histogram window stays empty and the image can not be developed.


      I have browsed through this forum some looking for the cause and the fix. There are some mentions of it, but they all date back to 2007.


      I run LR 2.2 on Windows XP SP2 and on a MacbookPro with OS X, version 10.5.8.


      Please help me understand the cause of this problem, and help me find a fix?





      Rotterdam, The Netherlands


        • 1. Re: What causes 'Unexpected end-of-file' error?
          J McWilliams Level 4

          I'd try deleting the Previews folder on the PC, with LR closed, then choosing the recent folders and force-build new Previews to see if that cures it.

          • 2. Re: What causes 'Unexpected end-of-file' error?
            RogierBos Level 1

            Thanks for the reply. Not sure how to do that.

            Where do I find that folder?

            Will it delete all preview images for all the images I've loaded?

            How do I 'force-build' new Previews?

            I am not sure why you would think this would help - but at this point I am so desperate, I'll try anything!



            • 3. Re: What causes 'Unexpected end-of-file' error?
              J McWilliams Level 4

              The Previews folder is in the same directory as the .lrcat.

              Yes, it will delete all the Previews, but they will all be rebuilt anew. It might be instructive to note the size of the Previews folder before you delete it, and then after it has had a chance to rebuild the preview images.

              • 4. Re: What causes 'Unexpected end-of-file' error?
                RogierBos Level 1



                Since I have 42000 images in my LR Catalog I decided not to delete the whole Preview folder, but rather to create a new catalog. Into thhis new Catalog I loaded the images of yesterdays shoot. The problem was the same.


                I am uploading two images that show the problem. In one screenshot the image comes up, but appears damaged (see on right); in the other screenshot the error message comes up; there is no histogram; and the image appears muted.


                You might think 'the image has to be corrupted,' but Lightroom on the Mac has no problem with these files. I am tempted to think it is my camera after all: but I have two camera's, and it started happening to images from both camera's - and LR on the Mac has no problem with these images.


                On the other side, in ACR I am also seeing corrupt files (see uploaded image ACR problem).


                I am tearing my hair out. Why did this start to happen all of a sudden and what can be done to fix it?

                • 5. Re: What causes 'Unexpected end-of-file' error?
                  2bike Level 1

                  Today is the first time I have also found this error. I was working in Hong Kong and using Lightroom on a PC. At the end of the assignment I transferred all the files to a bunch of USB memory sticks and then transferred the contents to my Mac when back home. The files that throw up this error are all from one particular memory stick (brand new/never used). They are also NEF files. Looking around on the net I see people also having problems with NEF files and CF cards or readers resulting in the "unexpected end-of-file" error.


                  The files had been fine on the PC in HK so the errors were something that had crept in during the transfer to the USB stick.


                  The memory stick is a corporate branded unit made by Chipsbrand HK and was a freebie so I hadn't used it before. I use Sandisk CF cards and they have never been a problem. Have you tried using different cards and seeing if one or other is more prone to giving this error? Have you formatted your cards recently?


                  Anyway, just now I ran Disk Utility on the suspect USB stick and sure enough it shows files with errors and orphaned clusters. The other sticks are clear of errors and consequently there are no problems in Lightroom. Phew! So I suggest you check your memory cards for errors and repair or reformat them. It shows it is probably worth reformatting storage cards/sticks before use to be sure of them. I do routinely format the CF cards whenever I empty them so start afresh with each shoot. This was a practise recommended in Nikon forums and has been good advice I think. I was in a hurry and didn't format the memory stick on this occasion. Fortunately the level of errors is maybe 1:25 so I haven't lost too much. I reformatted the stick a few minutes ago, transferred some files to it and re-tested and it is now error free.


                  Hope this helps in your search for a solution to your particular errors. I fear the images, at least in RAW format, are probably lost. Some people say that opening in a non-Adobe programme as a TIFF does at least save the basic image but obviously with no further RAW processing available. Haven't tested this myself yet.

                  • 6. Re: What causes 'Unexpected end-of-file' error?
                    sfslim Level 1

                    I am having the same problem on my Mac Pro as well as my Macbook Pro, so it's not just a PC problem.

                    It didn't happen with my D300 .NEF files, but is happening with my Leica D-Lux 4, seemingly randomly, with both raw and jpeg.


                    Any help appreciated.


                    • 7. Re: What causes 'Unexpected end-of-file' error?
                      2bike Level 1

                      I noticed the problem after transferring the files from a work PC to my Mac via USB memory sticks. It is, I think, neither a Mac or PC thing, but more to do with errors introduced by defects in the storage media. I was also using a Panasonic LX3 (in many respects identical to your Leica) and none of its files were affected. I mentioned the NEF problems because others were speculating that maybe it was a problem limited to NEFs. Interesting that it is the other way round for you so that shows that it is not just a Nikon thing.


                      Have you tried formatting the SD cards that you use with the Leica? What make are they/it? Have you looked at the card(s) in Disk Utility to see if it shows errors (select your card when it appears in the Disk Utility window and use Verify Disk)?
                      • 8. Re: What causes 'Unexpected end-of-file' error?
                        Ian Lyons MVP & Adobe Community Professional



                        I run LR 2.2 on Windows XP SP2 and on a MacbookPro with OS X, version 10.5.8.






                        Try upgrading to Lr2.5

                        • 9. Re: What causes 'Unexpected end-of-file' error?
                          2bike Level 1

                          It happened to me with version 2.4 and there is no change in 2.5. Lightroom is flagging up an external problem. Photoshop (or rather ACR) has the same trouble with the damaged files.

                          • 10. Re: What causes 'Unexpected end-of-file' error?
                            Ian Lyons MVP & Adobe Community Professional

                            2bike wrote:


                            It happened to me with version 2.4 and there is no change in 2.5. Lightroom is flagging up an external problem. Photoshop (or rather ACR) has the same trouble with the damaged files.


                            In the past, the damage shown in the linked files has been tracked to an issue with USB port or device. I don't know if this is the case with your images, but it's worth checking. Trying a different card reader or connecting via FireWire are some of the things I would try.

                            • 11. Re: What causes 'Unexpected end-of-file' error?
                              2bike Level 1

                              Thanks Ian, and I am pretty certain now that in my case the problem indeed stemmed from one particular USB memory stick. Yesterday I erased its contents and after adding new files to it it appeared OK. Today I checked it in Disk Utility again and it showed problems with a number of the files, once again reporting orphaned clusters etc. I ran the Repair routine on it and it says it has repaired the volume. We'll see - I'll test again tomorrow. If it shows further problems I'll bin it as it just isn't worth the risk to further files.


                              It would be interesting if someone had the files that were reporting damaged in Lightroom still on their original as-shot card (I'm afraid i don't) and could try different methods of transfer to see if the errors are being introduced by a particular device as you say. If the original memory card and files are OK then the errors may not show up in all methods. However, if the problem is a corruption on the original card then, in theory, all transfer methods would reveal the same errors.

                              • 12. Re: What causes 'Unexpected end-of-file' error?
                                sfslim Level 1

                                I always format my card in the camera whether the Nikon or the Leica. it's a 2GB San Disk.

                                This doesn't happen with my CF cards.

                                I have run Disk Utility on the SanDisk, Repair Permissions etc.

                                Your suggestion that there could be a problem with the reader is a good one. I used one cheap reader with the Mac Pro originally and that may damaged some of the files by the time I tried them in the pc slot reader on my MacBook Pro.


                                By the way I really appreciate you all getting back to me so quickly.

                                I will get another reader and shoot off some uninportant pictures and get back to you. The ones I lost were of our Govenor.


                                All of this did shut down LR 2.5  (as in I could not open it again, even after rebooting and reinstalling). I'm going to stick with LR 2.4 for a while.

                                • 13. Re: What causes 'Unexpected end-of-file' error?
                                  2bike Level 1

                                  Are you using the same card in both cameras (I ask because your post implies that it is one SD card only)? I have heard that it is a bad idea to mix cards and cameras as the formatting is different for each make. Also I believe repeated formatting eventually degrades the card as there are a limited (though quite large) number of formatting cycles that can be performed. Did Disk Utility reveal that there were errors in the files on the card? Maybe get a dedicated SD only reader rather than a multi-card one. I have one that I picked up from an HP trade stand and it has been very good. My last trip that threw up the file errors I had a cheap Integral reader. However the files were uncorrupted on the PC and in my case I'm sure the damage was caused after the initial download when they were transferred to the dodgy USB stick.


                                  The "shut down" of Lightroom sounds serious. So far 2.5 is working fine for me.

                                  • 14. Re: What causes 'Unexpected end-of-file' error?
                                    rxfelix Level 1

                                    While the corruption in your .NEF file could come from any one of a number of sources, here is a way to recover at least some of the information if you own Adobe Acrobat.  Your .NEF file should contain a smaller JPEG file created by your Nikon camera when the picture was taken.  Even if the .NEF file is corrupt, the JPEG may well be intact, and you can tell that's the case if a preview is visible in Lightroom or Bridge. 


                                    If you try to print it from Bridge or Lightroom, though, you will get an error.  You can get around this by loading up a CODEC that will let you preview the files in Windows Photo Gallery.  Nikon has one available for download to use with Vista x32 at http://www.nikonimglib.com/nefcodec/index.html.en, but it doesn't support Vista x64, so if you're running that (as I am) you'll need a second party CODEC such as the one available from http://www.ardfry.com/Products.htm with a 15-day trial download available.  They also have a DNG CODEC which I have not tried.


                                    With that CODEC installed and your system rebooted, preview the damaged NEF file in Windows Photo Gallery.  Choose the "Print" option and select the "Adobe PDF" printer.  Choose the "Postscript Custom Paper Size" option, and set the dpi resolution to the highest available (4000).


                                    Go to the "Options" link on the bottom right of the window and uncheck the "Sharpen For Printing" box, as you can do this yourself with later processing.  Then go to the "Printer Properties" link to see the Adobe PDF settings.


                                    Go to the Adobe PDF Settings tab and choose Default Settings: High Quality Print, which will set the resolution to 2400 dpi. 


                                    You want to have Acrobat interfere as little as possible with the output, so select "Edit" from the Default Settings tab, which will bring up the "High Quality Print - Adobe PDF Settings" dialog.  Here, turn off the "Optimize for fast web view" check box, then go to the "Images" folder and set the "Downsample" setting to Off and the pixels per inch to 2400.  Also, set "Compression" to Off.


                                    If you're going to do this in the future, you can also "Save As ..." your settings for future use with a name like "Fix Bad NEF Files."


                                    Print the file to a designated folder.  It won't be quite as good as the NEF file would have been, but at least you haven't lost the shot.

                                    • 15. Re: What causes 'Unexpected end-of-file' error?
                                      IanHylands Level 1

                                      I have had the same problem with LR 2.5 and ACR 5.5 now for several months. I have the problem with NEF files from my Nikon D3 and D700. I was using Lexar Pro UDMA cards and a Lexar firewire 800 reader on my Macbook Pro when it started happening. I have since switched to brand new SanDisk Extreme Pro cards and a SanDisk Firewire 800 card reader, with no change in the problem. It is intermittent. Some cards will will import fine one day, and not the next. The problem seems to be Lightroom Centric, if I import files using Lightroom and they are corrupt I can usually drag and drop the files from the card into a folder and then import them and they are fine. Does anyone actually have a solution to this problem or should I try to find a different software import option?

                                      • 16. Re: What causes 'Unexpected end-of-file' error?
                                        2bike Level 1

                                        Just a thought. Have you, or anyone else on the thread, tried doing a complete reinstall of Lightroom? I have had no problems with importing on my Mac since encountering the issue and wonder if it was the other PC installation that triggered my problems - not because it was a PC, this issue seems to be one that affects both platforms, but maybe there was some glitch in that particular installation. Another thought, which may be a complete red herring - that PC installation was based on the downloaded trial software and my untroubled Mac install is from the purchased disc.

                                        • 17. Re: What causes 'Unexpected end-of-file' error?
                                          IanHylands Level 1

                                          I've switched to a brand new Mac Book pro with the same problems, and my install is from the DVD, not the download. It didn't always happen, but it seems to happen more and more regularly. It's usually not a problem if I transfer the files to the correct folder by another method and then import from LR without moving them. So it seems to be an issue LR has when moving files from one location to another. I just can't figure out why it would be getting worse over time...

                                          • 18. Re: What causes 'Unexpected end-of-file' error?
                                            2bike Level 1

                                            Have you tried the LR3 beta? What happens if you make duplicates of a folder that has shown problems and then run them into a new LR3 catalogue as a test (given that the beta won't work with existing catalogues)? I know when i got problems with the USB stick i wasn't using Lightroom to do the transfer, just copied the folders direct to the stick. I only noticed the problem when reopening the catalogue and files on my home machine.

                                            • 19. Re: What causes 'Unexpected end-of-file' error?
                                              IanHylands Level 1

                                              I don't really have time to mess around like that. Now I just transfer everything manually from the card to a folder and then import into LR from there. That seems to prevent any problems. I'll be switching to the 2.6 Beta this week when I pick up my D3s so I'll let you know how that works.

                                              • 20. Re: What causes 'Unexpected end-of-file' error?

                                                I also ran into this problem 'Unexpected end-of-file' error. My Photoshop document took several hours to complete and then it was unable to open. My fix was to go back in time (using time machine, in OS 10.6.2). I selected the file from an earlier backup and voila. It would be nice to find out what is causing the problem in the first place though.


                                                • 21. Re: What causes 'Unexpected end-of-file' error?
                                                  IanHylands Level 1

                                                  I still haven't heard anything from Adobe on this, and same with a few other people. It seems like they're too busy to deal with this kind of stuff if they don't have a ready answer. Too bad. I haven't had any problems yet with 2.6, but I'm also not using an Adobe product to transfer the files from the card which is where my previous problems seem to have come from.

                                                  • 22. Re: What causes 'Unexpected end-of-file' error?
                                                    Winjeel Level 1

                                                    I've had this happen for the first time just now. I've imported a huge number of images taken yesterday at a sumo tournament, using a

                                                    brand new memory card. I've gone through flagged the ones I want in the Library module, then as I'm going through them in the Develop module, I'm using a preset I made (a white balance adjustment) and one of the flagged files gave me that message. Since others believe they've traced the source of the error to their memory sticks... I'm not sure if the error occurred because of the new memory card, or from the external hard drive I'm using. I'll admit, the external hard drive is about 4 years old, it's summer, it doesnt have any ventilation or cooling of its own, but its a small 20Gb pocket drive. Now I'm getting worried.


                                                    Edit: just adding, I'm using LR v2.7

                                                    • 23. Re: What causes 'Unexpected end-of-file' error?
                                                      Jonathon LeFaive Level 3

                                                      Did you format the new card in your camera before you shot with it?

                                                      • 25. Re: What causes 'Unexpected end-of-file' error?
                                                        IanHylands Level 1

                                                        There seem to be several causes, one of them is faulty cards or card errors, the other is a pretty big problem with LR itself that Adobe refuses to comment on. I get file errors, missing preview images etc. fairly regularly on several different machines with different versions of LR. I sometimes have to import a file 3 or 4 times to get it to import properly without problems. It happens to me most frequently when synching or updating folders or when there is only 1 file to import. The file is already on my computer in the folder, nothing wrong with it, yet when LR imports it there are errors. This also happeens to random files on import. I usually then copy them over using Bridge or something to make sure they're alright and then keep trying til LR gets it right. I really wish Adobe would fix or even just acknowledge this issue.

                                                        • 26. Re: What causes 'Unexpected end-of-file' error?
                                                          Winjeel Level 1

                                                          Thanks for the insight. I'll try a few things and see what works.


                                                          • 27. Re: What causes 'Unexpected end-of-file' error?
                                                            josephallannz Level 1

                                                            I believe some of the problems above are related to Edit > Catalog Settings... > Metadata > EXIF > Write date or time changes into proprietary raw files.  If this is selected and you change the capture time on your images then around 1 in 256 photos will become corrupted.  The problem is one in 256 files will end with character 26 (or character 1A in Hex).  When updating the files Lightroom removes the trailing character 26.  First of all turn off this switch.  Secondly if you don't have a good original copy you can download and use HEdit to append the trailing character 26 to your file.


                                                            I first posted this problem in September 2007 on the forum.  It is still an issue in the 3.2 RC.  I have reported the bug through adobe labs (correct channel rather than this forum) and they are looking into the problem.





                                                            If you are having problems with lots of images then obviously the issue is something else.


                                                            • 28. Re: What causes 'Unexpected end-of-file' error?
                                                              Jochen F. Uebel Level 1

                                                              We fixed the problem (regarding saving on a server) with one small trick:

                                                              no file preview.


                                                              Jochen Uebel

                                                              • 29. Re: What causes 'Unexpected end-of-file' error?
                                                                awesumtoy Level 1

                                                                This is the first time I have received this problem. Not only do I get end-of-file error, most pictures after it get distorted lines. I shoot with a Canon and a UDMA 7 high grade card. I have checked all my memory on the PC, no problems there. I have checked my disk drive and all sectors were good (I have a 2 TB hard drive so this took all night). I have no hard ware problems as some have said. I can open up all my Raw files in other software, just not Lightroom 5. I have even copied all the Raw files to another directory and imported them into lightroom, and I have the same problem. I then started with a new catalog and the problem got worse. I'm lost on how to fix this.

                                                                • 30. Re: What causes 'Unexpected end-of-file' error?
                                                                  josephallannz Level 1

                                                                  What other software are you using to open up the Raw files?

                                                                  • 31. Re: What causes 'Unexpected end-of-file' error?
                                                                    awesumtoy Level 1

                                                                    I was using Lightroom V5. I also tried it in Canon's DPP and Photoshop. All the photos are bad in whatever program I use. I am now thinking it is the CF memory card.

                                                                    • 32. Re: What causes 'Unexpected end-of-file' error?
                                                                      jesse63 Level 1

                                                                      Hi all


                                                                      I'm having the same problem with my Nikon D700 NEF-files and Lightroom 4. This is definately a Lightroom issue, and the reason I say this, is based on the following observation:


                                                                      I have made a Ligthroom-installation on both my stationary iMac and my MacBook Pro 15". Only difference is that I recently upgraded my MBP OS from Snow Leopard to Mountain Lion. A week ago, I transfered hundreds of NEF-files through a USB card reader to the iMac. All files showed perfectly in Lightroom on this machine. I subsequently copied the files from the iMac to  MBP via local network, imported to Lightroom and bingo – end-of-file errors. So this has nothing to do with the CF-cards.


                                                                      The problem is relatively new to me. I've had a very rugged and stable setup for years, but somewhere along different upgrades, things have turned unstable. I can't help thinking it might be connected to the recent Moutain Lion upgrade. But as I read things posted here, even brand new hardware + new installations are giving headaches.


                                                                      I think it would be the least Adobe could do, to point out some solutions and address this serious issue, that damages vital image files, and leaves customers in despare.


                                                                      PLEASE, Adobe  –  speak to us!

                                                                      • 33. Re: What causes 'Unexpected end-of-file' error?
                                                                        2bike Level 1

                                                                        Out of interest - have you tried converting the NEF files to DNG and then transferring them? Do they still get corrupted?

                                                                        • 34. Re: What causes 'Unexpected end-of-file' error?
                                                                          jesse63 Level 1

                                                                          I have most likely solved my problem with the corrupted RAW-files. The most logical explanation in my case is, that in conjunction with an upgrade to Moutain Lion, I also installed an 8 Gb RAM upgrade. This was a well known and recognized brand, sold by a widely trusted vendor. I was advised in another forum to check the RAM with the shareware REMBER, wich instantly diagnosed the RAM as defective.


                                                                          So looking back, the math seems to be quite simple. The defective RAM have messed up the file handling, both when reading RAW files from flash cards, and when archiving to external hard drives. I haven't encountered problems since I replaced the RAM with new ones, that passed the REMBER test.

                                                                          • 35. Re: What causes 'Unexpected end-of-file' error?
                                                                            Wodyetia Level 1

                                                                            Have just encountered this problem over the last few weeks.

                                                                            I was unable to import into LR 5 or to convert to DNG with Adobe converter.

                                                                            I have D800Es x3 and ceased using the CF cards hoping this may be the answer but still occurred affecting the first 7 images on card.

                                                                            I have downloaded direct from cards to iMac using card slot - no external card reader

                                                                            After reading the posts I tried some experiments.

                                                                            It appeared impossible to open these images with Photoshop from desktop or from within Bridge. or to import into LR 5

                                                                            The images opened in Capture One without a problem.

                                                                            I made a few adjustments in C1 and saved as NEF - this file would not open in PS

                                                                            Saved as tiff and the tiff file opened in PS CC no problem.

                                                                            Perhaps someone from Adobe will read this & do something about it.

                                                                            I imagine I am like many photographers who were dismayed by Adobe's new policies. I have been using LR 5 and fairly happily, but if I have to go through this rigmarole every time the fault occurs then my choice is simple as I can still use PS 6 on the few occasions C1 does not suffice.

                                                                            • 36. Re: What causes 'Unexpected end-of-file' error?
                                                                              ssprengel Adobe Community Professional & MVP

                                                                              Can you post an example raw image that won’t work in Adobe products?  Upload to DropBox and post a public download link.

                                                                              • 38. Re: What causes 'Unexpected end-of-file' error?
                                                                                ssprengel Adobe Community Professional & MVP

                                                                                The data in that NEF file appears to be corrupted, as seen in RawDigger a raw-analysis program:



                                                                                There is a full-resolution JPG embedded at the beginning of the raw file.  Can you tell if C1 is just truncating the corrupted area or if it is, perhaps, ignoring the raw data, and showing the extracted JPG?


                                                                                • 39. Re: What causes 'Unexpected end-of-file' error?
                                                                                  Wodyetia Level 1

                                                                                  A similar file imported into C1 has dimension 7360x4912 and when saved as dng is 72Mb.

                                                                                  the above NEF file saved as tiff is 202Mb so it would appear that C1 is opening the NEF file and not the jpg

                                                                                  the dng and tiff  files saved from C1 will now open in Photoshop without the 'could not complete...unexpected end of file was encountered' message

                                                                                  The original NEF file opened with Graphic Converter as full size file

                                                                                  1 2 Previous Next