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 in 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, just use PowerShell to run this script file.

image

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 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, make sure ffmpeg is installed and the environment variables are configured.

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