I have my files saved as a file on my hard drive. (Not in the database).
I will get the height and width of these * .jpg files, how to do this?
(Background: I have to calculate the ratio between height and width to bring it to the specified height and width without stretching it).
Many formats support a header with this information, but others do not ...
Image img = System.Drawing.Image.FromFile(path); int height = img.Height; int width = img.Width;
, , System.Drawing.Image IDisposable, using Dispose() , , . :
using (Image img = System.Drawing.Image.FromFile(path)) { int height = img.Height; int width = img.Width; }
Use the FromFile static method in the System.Drawing.Bitmap class to load images. The returned Bitmap instance has the Width and Height properties. In addition, you can also build a new Bitmap, passing the string path to your image file as a constructor parameter.
Source: https://habr.com/ru/post/1787741/More articles:What is C # the most efficient Delphi TStringList analogue? - objectHas Microsoft changed the way a string is passed as a parameter in ASP.NET MVC 3? - asp.net-mvc-3smell of synchronization code? - synchronizationproblem with primerfaces gmap tag - primefacesHow to write a query to remove duplicates in a table? - sqlStoring NULL instead of empty row columns - .netHTML source displayed in Firebug in standard browser "View Source"? - domHow does VirtualizingStackPanel decide when to unload (delete?) Virtualized controls? - wpfUse default LLVM compiler for all Xcode projects? - iphoneUpdate +1 line in CakePHP - cakephpAll Articles