Are you still worried about the cover image? With this script, you can automatically download images and achieve freedom in choosing cover images.
Code Implementation#
echo "---- Fetch Image ----"
# Current time
$t = Get-Date -Format "yyyy_MM_dd_HH_mm_ss"
# Anime picture API
$uri = "https://t.alcy.cc/pc/"
# File name
$filename = $t + ".webp"
echo $filename
Invoke-WebRequest -Uri $uri -Outfile $filename
echo "---- Fetch Image ----"
How to Use#
Write the above code into a ps1
file. Whenever you want to get an image, simply run the script file using PowerShell
.
2024-07-28: Adding Image Compression Functionality#
The new code is as follows:
# Get an anime picture
Write-Output "---- Fetch Image ----"
# Current time
$t = Get-Date -Format "yyyy_MM_dd_HH_mm_ss"
# Anime picture API
$uri = "https://t.alcy.cc/pc/"
# File name
$filename = $t + ".webp"
Write-Output "filename: $filename"
# Download
Invoke-WebRequest -Uri $uri -Outfile $filename
# Compress the image (quality q=5)
$input = $filename
$output = $t + "_compressed.webp"
ffmpeg -i $input -q 5 $output
# Delete the original image
Remove-Item $filename
Write-Output "---- Fetch Image ----"
Note: Image compression requires
ffmpeg
. Before running the script, please make sure thatffmpeg
is installed and the environment variables are properly configured.