oozcitak / exiflibrary

A .Net Standard library for editing Exif metadata
MIT License
131 stars 48 forks source link

[FEATURE] Add protected constructor to start with empty JPEGFile? #74

Closed ziriax closed 4 years ago

ziriax commented 4 years ago

This is related to #71, but would be a tiny change, that would make my live easier.

Would it be possible to add an empty (potentially protected) constructor to JPEGFile, that starts with an instance without any sections?

E.g.

        protected JPEGFile(Encoding encoding)
        {
            Format = ImageFileFormat.JPEG;
            Sections = new List<JPEGSection>();
            TrailingData = new byte[0];
            Encoding = encoding;
         }

This would allow inheritors to customize the behavior, e.g. to use the class for writing only :)

Not sure if this would work, I'm going to make a fork, try it out, and then submit a PR.

But maybe we can discuss this already.

oozcitak commented 4 years ago

I thought something like this would be required as you are creating a metadata-only image from scratch. You can add the protected constructor into your PR if you like; I don't have any objections.

ziriax commented 4 years ago

I tested this by just passing the SOI bytes to JPEGFile constructor, and that seems to work :)

So actually no real need yet for an empty constructor, I can work around it, but it would of course be nicer.