Results 1 to 4 of 4
  1. #1
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Find Size of JPEG

    Within the context of an Access database, I need to programmatically find the size of some jpg images. If they are larger than a nominated size, I then want to reduce the size (using IrfanView). Now I have been doing this for years, but now the process has started throwing errors.

    I attach the function I use. This function is one I found somewhere a few years ago, but I don't understand enough about the internal structure of jpgs to know what it is doing.

    One of the people who use this has just bought a new camera, and he has set it to take photos that are much larger than he needs.
    When I run the procedure using an image that is 1504 x 1000 pixels, it throws an overflow error at line 240.
    If I put in the debug.print line before it, I get an overflow error at line 230? Any ideas?
    Attached Files Attached Files
    Regards
    John



  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Find Size of JPEG

    The function you posted worked OK for me on a picture of 3736 by 2823 pixels.

    You'll find an alternative function in <post:=682,264>post 682,264</post:>. It can be used to retrieve all kinds of extended information about .jpg files, .mp3 files etc. To retrieve the width and height, specify 26 as second argument. The return value will be a string in the form "800 x 600". You can easily parse this to obtain the width and height.

    Example:

    Debug.Print GetProperty("C:PicturesMyHouse.jpg", 26)

  3. #3
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Find Size of JPEG

    Thanks Hans.

    That looks better than the function I have been using.

    I think there must be something unusual with this particular batch of photos.
    Regards
    John



  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Find Size of JPEG

    I've encountered some .jpg files that apparently have a non-standard header. They cannot be opened by MS Paint or Windows Picture and Fax Viewer, but IrfanView and FastStone MaxView are able to handle them. Perhaps the pictures that cause problems for you have non-standard headers too.

Posting Permissions

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