https://github.com/doxakis/imagesizereader
Getting image dimensions without reading an entire file.
https://github.com/doxakis/imagesizereader
Last synced: 12 months ago
JSON representation
Getting image dimensions without reading an entire file.
- Host: GitHub
- URL: https://github.com/doxakis/imagesizereader
- Owner: doxakis
- Created: 2020-02-25T04:57:59.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-02-26T22:39:34.000Z (over 6 years ago)
- Last Synced: 2025-06-06T17:09:29.191Z (about 1 year ago)
- Language: C#
- Size: 7.81 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Image size reader
Getting image dimensions without reading an entire file.
- No GDI+ involved here, only pure c#
- Optimized for memory consuption and being cloud friendly
- Early stop when it cannot determine the dimensions
# Install from Nuget
To get the latest version:
```
Install-Package ImageSizeReader
```
# How to use
```
import ImageSizeReader;
import ImageSizeReader.Model;
// ...
Stream fileStream = File.OpenRead(file);
IImageSizeReaderUtil util = new ImageSizeReaderUtil();
var dimensions = util.GetDimensions(fileStream);
// dimensions.Width
// dimensions.Height
```
## Notes
Originally, this is based on https://stackoverflow.com/a/112711 and associated comments to handle edge cases.
It has been tested with lot of different images. For example the [ImageSharp repo](https://github.com/SixLabors/ImageSharp) has many useful images for testing.
In order to improve the Jfif (aka JPEG File Interchange Format) decoding, the following page has been useful:
http://vip.sugovica.hu/Sardi/kepnezo/JPEG%20File%20Layout%20and%20Format.htm
# Copyright and license
Code released under the MIT license.