Results 1 to 3 of 3

Thread: [RESOLVED] Getting image size is wrong - please help

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2000
    Posts
    1,463

    Resolved [RESOLVED] Getting image size is wrong - please help

    Hi everyone,

    I am loading an image with the code below. The image is a portrait image that is 2000 wide and 4000 height. But when I run it through this code the Format2 is set to "L". I don't understand because I even put a breakpoint in the code and looked and the Height and Width properties for img and they were reversed as if it is a landscape image. I opened the image file multiple times and even looked at the properties of the image and it showed it as 2000 wide and not 4000 wide. Does anyone know why this would happen?

    Thanks,
    Warren
    Code:
            Dim file2 As String = "C:\port.jpg"
            Dim img As Image = Image.FromFile(file2)
            Dim Format2 As String = "P"
            If img.Height < img.Width Then Format2 = "L"

  2. #2
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,122

    Re: Getting image size is wrong - please help

    Perhaps you are not using your Format2 variable correctly. How do you use it?

    If your image is a photo from a digital camera, the image is generally stored in Landscape orientation but contains EXIF data to say whether the intended orientation is Landscape or Portrait. Any decent image viewer will read the EXIF data to decide the orientation. You can do that in VB.Net too. Probably that is why your viewer reports the size as 2000 * 4000.

    BB

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2000
    Posts
    1,463

    Re: Getting image size is wrong - please help

    I am using an image from my mobile app. Last night I did a work around on this and in my app I am determining if it is portrait or landscape by the height and width. Then I am passing that as a parameter with the image to my asp.net page so I know what to do with it. I take a picture with the app, send it to the server to be changed and then have the app download the new image back to use. I am not using any additional control to do the image work so its all in .NET. Hopefully this will work for now. But I will remember about the EXIF data.

    Thanks,
    Warren

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width