banner
Tenifs

Tenifs

雄关漫道真如铁,而今迈步从头越。
github
follow
zhihu
email

Get a two-dimensional image

Are you still worried about the cover image? With this script, you can automatically download images and achieve freedom with cover images.

Code Implementation#

echo "---- Fetch Image ----"
# Current time
$t = Get-Date -Format "yyyy_MM_dd_HH_mm_ss"
# Anime image API
$uri = "https://t.alcy.cc/pc/"
# File name
$filename = $t + ".webp"
echo $filename
Invoke-WebRequest -Uri $uri -Outfile $filename
echo "---- Fetch Image ----"

Usage Method#

Write the code above into a ps1 file, and whenever you want to get an image, just use PowerShell to run the script file.

image

2024-07-28: Added Image Compression Feature#

The new code is as follows:

# Get an anime image
Write-Output "---- Fetch Image ----"
# Current time
$t = Get-Date -Format "yyyy_MM_dd_HH_mm_ss"
# Anime image API
$uri = "https://t.alcy.cc/pc/"
# File name
$filename = $t + ".webp"
Write-Output "filename: $filename"
# Download
Invoke-WebRequest -Uri $uri -Outfile $filename
# Compress image (quality q=5)
$input = $filename
$output = $t + "_compressed.webp"
ffmpeg -i $input -q 5 $output
# Delete original image
Remove-Item $filename
Write-Output "---- Fetch Image ----"

Note: Image compression uses ffmpeg. Before running the script, please ensure that ffmpeg is installed and the environment variable is configured properly.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.