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

feat: Create a favicon for an artist based on their avatar #912

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

lenikadali
Copy link

Fixes #330

  • Adds sharp-ico package, using that library to create the artist favicon from the artist avatar

Added the sharp-ico package and tried to generate a favicon
based on the artist avatar we have.
Copy link

netlify bot commented Nov 21, 2024

👷 Deploy request for mirlo pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 764fdcb

Fixed comment to match JS style comments
Copy link
Member

@simonv3 simonv3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing, thanks for doing this!

Added a comment that i think should help

@@ -148,6 +150,17 @@ const optimizeImage = async (job: Job) => {
data: { url: urls },
});
} else if (model === "artistAvatar") {
// TODO: where should the favicon be stored
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can store it on minio, for which there's a utility library in minio.ts.

You can see an example of it being used here https://github.com/funmusicplace/mirlo/pull/912/files#diff-115f11f048b07ecdfa25349373f3479306ff732a6f8185f5590f98f114d211dbR114

Added call to upload the artist avatar favicon
to the Minio store and some logging
to indicate when it happens
@lenikadali lenikadali marked this pull request as ready for review November 27, 2024 16:58
Comment on lines 152 to 162
artistFavicon = ico.sharpsToIco([sharp(buffer)], "artist_avatar.ico", {
sizes: [48],
resizeOptions: {},
});
logger.info("Uploading artist avatar favicon to bucket");
const faviconFinalName = `${destinationId}_favicon.ico`;
await minioClient.putObject(
finalMinioBucket,
faviconFinalName,
artistFavicon
);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simonv3 I've tried to store the favicon in Minio as you suggested. Let me know if I got it right 😅 🙏

Copy link
Member

@simonv3 simonv3 Nov 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks good! If you're running this locally, you can check to see if it ended up there, instructions on how to access it here: https://github.com/funmusicplace/mirlo?tab=readme-ov-file#minio

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to update the implementation as shown in commit 32d8288 but now works (file appears with the name in the artist avatar bucket)

In commit 764fdcb I tried to make sure that the favicon file name is unique to each artist avatar.

Removed the artistFavicon variable since the return value
of the ico method is the size, width and height properties
of the favicon. Switch to setting the file name as a variable
and use that when saving the favicon to the Minio bucket.
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

Successfully merging this pull request may close these issues.

Create a favicon for an artist based on their avatar
2 participants