webp-convert icon indicating copy to clipboard operation
webp-convert copied to clipboard

Extract code for abstract converter into new library

Open rosell-dk opened this issue 2 years ago • 2 comments

The new library will basically take care of all related to converting besides the actual converting. But it must be be generic enough to be used with both webp-convert and avif-convert (and other possible libraries, such as one for jpeg 2000).

The AbstractConverter class and its traits can (more or less) be extracted into a this new library (ie "AbstractImageConverter") The loggers can also be put into this library (or a new). Any helpers regarding conversion (that are not worthy of their own library) can go here too. Looking into actual converters, ie "ImageMagick.php", I see there would be a lot of code duplication in AVIFConvert. It should be considered how to avoid that. One idea could be to provide a generic base class for each converter or perhaps a trait instead.

It should be kept in mind that we might want to create a library "ImageConvert" which is able to pull it all together, allowing conversion between "any" image type.

It must not necessarily be implemented exactly as now. I have used a lot of inheritance and traits, but maybe some would be clearer with composition.

rosell-dk avatar Apr 18 '22 16:04 rosell-dk

Another way around would be to have all the code in a new library "image-convert". webp-convert could simply use that new all-encompassing library

rosell-dk avatar Apr 20 '22 08:04 rosell-dk