GSoC 2024: Picard image processing

Hello, I’m Giorgio Fontanive (aka twodoorcoupe), a computer engineering student from Italy. For the past few months I’ve been working on Picard under the mentorship of zas and outsidecontext.

Objective

Currently, Picard can retrieve releases’ cover art images from multiple providers and embed these into music files’ tags or save them as separate files. While most cover art providers allow some options over things like size, the user still has little control over the final images.

The goal of the project was to fix this by adding more options to filter and to post process images, independent of the provider, while also having different options for images embedded into tags and the ones saved as separate files.

Project Overview

Picard will have a new options page called “Processing” under the “Cover Art” page. Here you can choose to filter images below a certain size, resize images, and convert to a different format. There is also the possibility to create plugins which add more filtering and processing options. These changes will be available once Picard 3.0 releases, and there will also be a new page in the documentation to guide users to the new features.

One of the first decisions regarding the project was what library to use for the actual image manipulation. I considered a few alternatives, but I proposed to use Qt’s image functionalities, since Picard already uses Qt, and I could avoid adding more dependencies. Still, if the need arises, these features were designed in a way that makes it easy to switch to a different image library later on.

Filters

The size filter was implemented first in this pull request. Its functionality is simple, if the image downloaded does not meet the size criteria, it is discarded. Some providers can even skip the download of the image altogether, if they have a way to retrieve the image size before.

There are also a couple more filters in the “Cover Art” options, which were added in this pull request. You can choose to never replace images of the same type with smaller ones, and to never replace images of the selected types.

Processors

The image resizing options were initially added by this pull request, and were later improved upon by this other one. There are five resize modes: maintain aspect ratio, scale to width, scale to height, crop to fit, and stretch to fit. You can also choose whether to allow images to increase in size. The UI of these options went through several iterations. With the suggestions of Aerozol and rdswift, the final result was added in this pull request.

Format conversion options were added in this pull request. The available formats are JPEG, PNG, WebP, and TIFF.

You can view the result of image processing by clicking on “Show More Details” below the cover art thumbnail in the bottom right. It will show you both the new image that will be embedded into tags, and the one that will be saved as a separate file, if the respective options are enabled. This feature was added in this pull request.

My last task, and probably the hardest, was to make image processors run in different threads. This is to allow Picard to manipulate the images while the next one in the queue is being downloaded, thus saving time. This was implemented over a couple of pull requests, as I had to make additions to other parts of Picard’s code, but the main chunk was introduced in this pull request.

Experience

This experience was incredibly rewarding and helpful. I’m glad I was able to implement everything I initially set out to accomplish. Over the course of the past summer, I learned the importance of planning things, but being flexible to changes and unexpected issues. I also gained confidence in working with large code bases and open source communities.

Thanks to Metabrainz for giving me this opportunity. Thanks to my wonderful mentors outsidecontext and zas, who were very thorough and patient with me in these past few months. Also thanks to rdswift, Aerozol, and Sophist, who gave me tips and suggestions along the way. I look forward to continuing working on Picard!

Leave a Reply

Your email address will not be published. Required fields are marked *