Working code for URL Image moderation. It's not working for local images. I get a "remote server return error (400) Bad Request" I am not sure if I should convert the images to bytes. Any help is appreciated.
# Import necessary modules
# Set your API user and secret
$api_user = "#####"
$api_secret = "####"
# Set the path to the image you want to moderate
$image_path = "C:\Temp\Pictures\sportsillustrated.png"
$URL = "https://www.micds.org/wp-content/uploads/2018/06/WaterPolo-Varsity-Boys.jpg"
# Read the image into a byte array
$image_bytes = [System.IO.File]::ReadAllBytes($image_path)
# Convert the byte array to a base64 string
$image_base64 = [System.Convert]::ToBase64String($image_bytes)
# Set the API endpoint
$api_endpoint = "https://api.sightengine.com/1.0/check.json"
# Set the parameters for the API call
$params = @{
"models" = "nudity-2.0"
"url" = $URL
#"media" = $image_base64
'api_user' = $api_user
'api_secret' = $api_secret
}
# Make the API call
$response = Invoke-RestMethod -Uri $api_endpoint -Method Post -Body $params
# Output the response
$response