locked
The width of the image that is installed learn RRS feed

  • Question

  • User-770252936 posted

    Hi there. The width and height of the image that is installed on the server, how do I know?
    Example: "/ımages/firma/logo.jpg"
    The above image is installed in the directory, how do I get the width and height?

    Tuesday, August 26, 2014 6:31 AM

Answers

  • User1428246847 posted

    kortmazsefa

    Compilation Error              Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.            
    Compiler Error Message: CS0246: The type or namespace name 'Bitmap' could not be found (are you missing a using directive or an assembly reference?)

    Bitmap is a class, so you can search the web for 'Bitmap class' or 'MSDN Bitmap class'. The result (or one of them) is http://msdn.microsoft.com/en-us/library/system.drawing.bitmap%28v=vs.110%29.aspx

    Inheritance Hierarchy

    System.Object
      System.MarshalByRefObject
        System.Drawing.Image
          System.Drawing.Bitmap

    The last line tells you that Bitmap is part of System.Drawing, so adding a 'using' (C#) or 'import' (VB) should do the trick. Or use the below

    System.Drawing.Bitmap img = new System.Drawing.Bitmap("your file");

    I hope this helps you for future similar problems; at least you don't have to wait 5 hours before you can continue :D

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 26, 2014 1:59 PM

All replies

  • User-933257319 posted

    This is how we can get height and width of image
    Bitmap img = new Bitmap("your file");

    var imageHeight = img.Height;
    var imageWidth = img.Width;

    Tuesday, August 26, 2014 7:53 AM
  • User-770252936 posted

    Compilation Error              Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.            
    Compiler Error Message: CS0246: The type or namespace name 'Bitmap' could not be found (are you missing a using directive or an assembly reference?)
    Source Error:

    Line 685:                        </div>
    Line 686:                    </div>@{
    Line 687:                Bitmap img = new Bitmap(Server.MapPath("/Images/Firma/logo.jpg"));
    Line 688:
    Line 689:                var imageHeight = img.Height;
    Tuesday, August 26, 2014 8:04 AM
  • User1428246847 posted

    kortmazsefa

    Compilation Error              Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.            
    Compiler Error Message: CS0246: The type or namespace name 'Bitmap' could not be found (are you missing a using directive or an assembly reference?)

    Bitmap is a class, so you can search the web for 'Bitmap class' or 'MSDN Bitmap class'. The result (or one of them) is http://msdn.microsoft.com/en-us/library/system.drawing.bitmap%28v=vs.110%29.aspx

    Inheritance Hierarchy

    System.Object
      System.MarshalByRefObject
        System.Drawing.Image
          System.Drawing.Bitmap

    The last line tells you that Bitmap is part of System.Drawing, so adding a 'using' (C#) or 'import' (VB) should do the trick. Or use the below

    System.Drawing.Bitmap img = new System.Drawing.Bitmap("your file");

    I hope this helps you for future similar problems; at least you don't have to wait 5 hours before you can continue :D

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 26, 2014 1:59 PM