Skip to content

Instantly share code, notes, and snippets.

@geek-at

geek-at/example.sh

Created Aug 10, 2020
Embed
What would you like to do?
Bash example for nsfw-categorize.it
#!/bin/sh
# Test image1.jpg
curl -s -F "image=@image1.jpg" "https://nsfw-categorize.it/api/upload"
# Let the API analyze an externally hosted image
curl -s "https://nsfw-categorize.it/api/upload?url=https://i.imgur.com/wubvFTM.jpeg"
# Classify all images in a folder and save results to files
for filename in /home/user/photos/*.jpg; do
photo=$(basename $filename)
result=$(curl curl -s -H "NSFWKEY:your-key-here" -s -F "image=@/home/user/photos/$photo" "https://nsfw-categorize.it/api/upload" | jq -r .data.classification )
echo "$photo is classified as $result"
if [ "$result" = "porn" ]; then
echo "/home/user/photos/$photo" >> porn.txt
elif [ "$result" = "nsfw" ]; then
echo "/home/user/photos/$photo" >> nsfw.txt
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.