You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to add more thumbnails to my links, and thought about using one of the screenshot services, like browshot, but decided on something more hacky, which actually worked OK. The idea was to get the largest image from each page, which is often a banner, featured image or touch icon.
Requirements:
PhpMyAdmin access to your LinkAce DB (I am on Docker so just had to open the port to make it accessible from the host);
A web server you can host additional thumbnail images on
Exported a list of ids and urls from links with no existing thumbnail, save these to links.csv.
SELECT id, url FROM`links`WHERE thumbnail is null;
Shell script to loop though and download all the images from those pages (I needed to find/replace all quotes from the CSV first for this to work)
#!/bin/shwhile IFS=, read -r id link;doecho"The ID is $id, the link is $link";
mkdir ./$id
wget -nd -r -H -l 1 -T 3 -t 1 -P ./$id -A jpeg,jpg,png $linkdone< links.csv
Python script to loop through and select the biggest images, rename, and output SQL update (used claude.ai for this, so it's better than my code would be)
importosimportshutildefget_largest_image(folder_path):
max_size=0largest_image=Noneforfilenameinos.listdir(folder_path):
file_path=os.path.join(folder_path, filename)
ifos.path.isfile(file_path):
size=os.path.getsize(file_path)
ifsize>max_size:
max_size=sizelargest_image=file_pathreturnlargest_imagedefrename_largest_image(folder_path, largest_image):
folder_name=os.path.basename(folder_path)
new_name=os.path.join(folder_path, f"{folder_name}{os.path.splitext(largest_image)[1]}")
os.rename(largest_image, new_name)
returnnew_namedefprocess_folder(folder_path, new_folder_path ):
largest_image=get_largest_image(folder_path)
iflargest_image:
new_name=rename_largest_image(folder_path, largest_image)
folder_name=os.path.basename(folder_path)
file_name=os.path.basename(new_name)
sql_statement=f"update links set thumbnail = 'https://your-web-hosting{folder_name}/{file_name}' where id = {folder_name};"print(sql_statement)
# Copy the folder and the renamed image to the new folder pathnew_folder=os.path.join(new_folder_path, folder_name)
os.makedirs(new_folder, exist_ok=True)
shutil.copy(new_name, new_folder)
# Example usageroot_folder="/path/to/folder"new_folder_path="/path/to/newfolder"forfolderinos.listdir(root_folder):
folder_path=os.path.join(root_folder, folder)
ifos.path.isdir(folder_path):
process_folder(folder_path, new_folder_path )
Upload the images to your web server and run the SQL update
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I wanted to add more thumbnails to my links, and thought about using one of the screenshot services, like browshot, but decided on something more hacky, which actually worked OK. The idea was to get the largest image from each page, which is often a banner, featured image or touch icon.
Requirements:
Beta Was this translation helpful? Give feedback.
All reactions