Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I have a large collection of pictures in a folder.
I want to know the size of each image (width-height)
in centimeters
What is the best programming language
What is the code?

What I have tried:

I have no attempt
But from here I will start programming
to help myself
Posted
Updated 23-Sep-21 22:36pm
Comments
Richard MacCutchan 24-Sep-21 3:20am    
Image files contain the dimensions in pixels rather than real world measurements.

While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.
We aren't here to work on "from here I will start programming to help myself" because we have seen often enough that it rarely happens ...

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
 
Share this answer
 
What you request requires advanced skills to implement for a specific context (language, development environment, image formats, hardware). imho, you'll need to develop your skills and knowledge for a specific context ... like C#, Windows, Visual Studio, WinForms ... and, you'll need to do a lot of experimenting. For an introduction to graphics in WinForms, I'd recommend Rod Stephens' 2008 "C# Graphics Programming" [^].

WPF offers much more advanced graphics capabilities: [^]

Do keep in mind what Richard MacCutchan said about image file co-ordinates being independent of any device ! In C# I would access the image file's internal data using code like this: [^]
// Using System.Drawing.Image

        Image img = Image.FromFile(fileName);
        ImageFormat format = img.RawFormat;
        Console.WriteLine("Image Type : "+format.ToString());
        Console.WriteLine("Image width : "+img.Width);
        Console.WriteLine("Image height : "+img.Height);
        Console.WriteLine("Image resolution : "+(img.VerticalResolution*img.HorizontalResolution));

        Console.WriteLine("Image Pixel depth : "+Image.GetPixelFormatSize(img.PixelFormat));
        Console.WriteLine("Image Creation Date : "+creation.ToString("yyyy-MM-dd"));
        Console.WriteLine("Image Creation Time : "+creation.ToString("hh:mm:ss"));
        Console.WriteLine("Image Modification Date : "+modify.ToString("yyyy-MM-dd"));
        Console.WriteLine("Image Modification Time : "+modify.ToString("hh:mm:ss"));
Now, consider the factors that may influence the aspect ratio, and pixel dimensions, of your app when displayed on a monitor in Windows:

1) monitor resolution ... which can be set by the user
2) OS global front/window scaling factor ... which can be set by the user
3) video card capabilities ... hardware limits; user settings
4) AutoScaleMode setting in C# Visual Studio WinForms ... which can be set by the user

Then, consider if you are displaying the image in a container control, like a WinForms PictureBox, or, in WinForms, you are using the Paint event to render the image on some control.
 
Share this answer
 
v3
Comments
TheRealSteveJudge 24-Sep-21 5:26am    
5*

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900