From 74274f879e6271b66666d1cbb76d049de6fc536d Mon Sep 17 00:00:00 2001 From: Niels Simenon Date: Sat, 22 Feb 2020 23:50:25 +0100 Subject: [PATCH] Re-added image entropy filter. --- src/media.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/media.js b/src/media.js index 63cf2a5c..73bea226 100644 --- a/src/media.js +++ b/src/media.js @@ -231,7 +231,7 @@ function groupItems(items) { }); } -async function storeMedia(sources, domain, role) { +async function storeMedia(sources, domain, role, { entropyFilter = 2.5 } = {}) { const presentSources = sources.filter(Boolean); if (presentSources.length === 0) { @@ -250,7 +250,7 @@ async function storeMedia(sources, domain, role) { const { hash: fetchedItemsByHash } = groupItems(fetchedItems); // find hash duplicates that don't need to be re-saved - const uniqueFetchedItems = Object.values(fetchedItemsByHash); + const uniqueFetchedItems = Object.values(fetchedItemsByHash).filter(item => !entropyFilter || item.entropy >= entropyFilter); const existingHashItems = await knex('media').whereIn('hash', uniqueFetchedItems.map(item => item.hash)); const { hash: existingHashItemsByHash } = groupItems(existingHashItems);