locked
Image.FromFile is giving Out Of Memory Error... RRS feed

  • Question

  • User-1060547008 posted

    Hi friends,

    I am trying to crop a tiff image in c#.  But Image.FromFile(...) method is throwing error "Out of Memory".

    I analysed the situation and found that some images of tiff format are working fine and some are throwing error.  I also analyzed that

    images that are not working have one thing in common... i.e. when i checked the properties of these images i see that "Summary" tab is

    having no data...

    And there was data in summary tab for those images who were working fine...

    Plz help... 

     

     

    Sunday, November 30, 2008 7:30 AM

Answers

  • User187056398 posted

    It's possible the images were not written correctly.  Some applications can handle this better than others.  You may need to get a third party library to open, correct and save the images so .Net can read them.

    TIFF tags can be binary or text.

    Maybe .Net is looking for a null terminator in the summary tag and there is none.

    Maybe when there is no text, the saving program is putting -1 as the field length and .Net goes off looking for it.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 1, 2008 10:10 AM
  • User-744022866 posted

     the possible chances are

    1. the aspnet account dont have permission. - in this case you will get out of memory error. Check the permissions on the image file. Since using your windows account also you are unable to preview the image, there are chances that both aspnet acct and your windows account both dont have permission over the image. Try to copy the image and paste in somewhere else, if you succeed on this that means you have sufficient permission on this.

    2. the image file is not in right format.  This might be another option, since other applications opens this chances for this is less...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 1, 2008 11:19 PM

All replies

  • User-744022866 posted

     if you are getting out of memory error for imagefromfile method, check it is a valid image and aspnet machine account have access to it. Check the ACLs on the image

    Sunday, November 30, 2008 8:15 AM
  • User-1060547008 posted

    Images which are showing "Out of Memory" error are also not opening in imaging preview.But these images are opening in other applications such as Windows Presentation Foundation applications.  As i previously said that i think its happening just because these images are having no summary details(in summary tab) in their properties.

    plz help...

    Sunday, November 30, 2008 11:36 PM
  • User187056398 posted

    It's possible the images were not written correctly.  Some applications can handle this better than others.  You may need to get a third party library to open, correct and save the images so .Net can read them.

    TIFF tags can be binary or text.

    Maybe .Net is looking for a null terminator in the summary tag and there is none.

    Maybe when there is no text, the saving program is putting -1 as the field length and .Net goes off looking for it.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 1, 2008 10:10 AM
  • User-744022866 posted

     the possible chances are

    1. the aspnet account dont have permission. - in this case you will get out of memory error. Check the permissions on the image file. Since using your windows account also you are unable to preview the image, there are chances that both aspnet acct and your windows account both dont have permission over the image. Try to copy the image and paste in somewhere else, if you succeed on this that means you have sufficient permission on this.

    2. the image file is not in right format.  This might be another option, since other applications opens this chances for this is less...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 1, 2008 11:19 PM