1
0
-1

What methods are people using to find the dimensions for an image.  We want to be able to validate image files within a certain dimension range and file size range.  I have discovered how to get to file size but not image dimensions.  Any help is appreciated.

    CommentAdd your comment...

    3 answers

    1.  
      1
      0
      -1

      Perhaps I should have been more clear.  Im looking for a programmatic way to obtain image dimensions.  Our software has the ability to load images into the system and I'd like add validation based on the width and height, in addition to file size.  File size is already done. 

      The Windows Explorer method works well, as I've used it in the recent past for troubleshooting purposes.  If there was somehow a way to work with an API to get that information, I would be open to integrating that.  I briefly looked into the GDI+ API, and it looks like this might have some promise.  Anyone have any experience importing the GDI API into Uniface?  Ive not been successful using the /sti command to get gdi32.dll to import.  It tells me it uses a ProgID, but I havent been successful in finding that information as of yet.  If anyone has imported this before, I'd be curious as to how that was done.

      I'd prefer to use whatever methods are accessible to a native Windows environment, but am open to other ideas.  I'll definitely take a look at what Gianni suggested and see what the options are there.


      1. Gianni Sandigliano

        Hi Tim,

        I understand what you mean and ask for: you would prefer to have a dedicated library available, loading it as Uniface signatures and using DIRECT calls to it; in your example your expectation for your library call would be:
        - open the file.
        - read file header.
        - recognize from it: filetype, filesize, compression, image dimension, etc, ...
           in a sentence all image attributes.
        - give them back to your calling program.

        Yes, you can do that! Choose your preferred library, be sure it provides and properly install on Windows a type library, load its type library as Uniface signatures set then use them.

        (BTW: I know I put it simple but it is not always that simple like you probably has already found!)

        The way I propose you is NOT that direct but it is not complex and it works in a stable way from 25+ years; it was put together when Uniface didn't have yet signatures functionalities.
        I've started to implement it when we had a deal to catalog all italian cultural heritage with a company in Firenze; it was an hell of a work but we win that deal and some hidden forms (we will call them "services" starting from U7) has navigated my Uniface toolkit up to current days.

        If you will be unlucky with your preferred type library take in consideration Irfan Viewer enable you to do almost everything you need to do with images with its batch command mode.

        Regards,
        Gianni

      CommentAdd your comment...
    2.  
      1
      0
      -1

      Hi Tim,

      You can also use Windows Explorer

      Right click on the file and select Properties. The Details tab will show the dimensions and colour depth.

      It won't display as much info as a dedicated graphics editor like Irfan or Paint.Net. But if you only need the image pixel size, you should be ok with that.

      Cheers,

      Peter

        CommentAdd your comment...
      1.  
        1
        0
        -1

        Hi Tim,

        since 1993 I am using Irfan Viewer for whatever image functionality I need, with success. Irfan Viewer it is one of the most downloaded, stable, valuable and incredibly efficient software I know...

        In your specific case I would use one of the many command line option available:
            [FullPath]i_view{32|64}.exe PathToImage\ImageName.ext /info=FullPath\AtextFile.txt
        You can execute this using OS.Commandout() signature component to be able to eventually catch any error message then fileload the resulting text file and recognize all image informations you need, giving back as output a list; an example:

        [ImageFileName.ext]
        File name = ImageFileName.ext
        Directory = Disk:\FullPath\
        Compression = JPEG, quality: 90, subsampling ON (2x2)
        Resolution = 96 x 96 DPI
        Image dimensions = 1920 x 1080  Pixels (2.07 MPixels) (16:9)
        Print size = 50.8 x 28.6 cm; 20.00 x 11.25 inches
        Color depth = 16,7 Million   (24 BitsPerPixel)
        Number of unique colors = 153623
        Disk size = 555.11 KB (568.435 Bytes)
        Current memory size = 5.93  MB (6.220.840 Bytes)
        File date/time = 20/11/2020 / 13:44:46

        There is also /fullinfo command line switch dedicated to EXIF, EPTC and Comment infos.

        Hope it helps.

        Regards,
        Gianni

          CommentAdd your comment...