Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I get the dimensions (height and width) of pictures #329

Open
mrboring opened this issue Jul 19, 2023 · 2 comments
Open

How do I get the dimensions (height and width) of pictures #329

mrboring opened this issue Jul 19, 2023 · 2 comments

Comments

@mrboring
Copy link

Hi

I have mp3 files with pictures. I want to check that the height and width are not greater than 300 pixels. I can see Tag.Pictures which contains various information, but not the dimensions. I'm guessing that the Data property might contain this information.

How do I get the dimesions?

Thanks.

@jerry08
Copy link

jerry08 commented Aug 11, 2023

@mrboring I don't think you can get those details from taglib-sharp. I suggest you use ImageSharp to get the image info. For example:

using SixLabors.ImageSharp;
using TagFile = TagLib.File;
var filePath = "...";
var file = TagFile.Create(filePath);
var pics = file.Tag.Pictures;

var imgBytes = pics[0].Data.Data;

var image = Image.Load(imgBytes);
var height = image.Height;
var width = image.Width;

@mrboring
Copy link
Author

@jerry08, Thanks, this is very helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants