-
Notifications
You must be signed in to change notification settings - Fork 0
/
gptimage.sh
43 lines (37 loc) · 1.26 KB
/
gptimage.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
query=$(zenity --entry --text="Enter the desired keywords separated by a comma to generate the image, or type 'exit' to quit:")
while [ "$query" != "exit" ]
do
url=$(python3 - <<END
import openai
openai.api_key=" "
def img_gen(query):
response = openai.Image.create(
prompt=query,
n=1,
size="1024x1024"
)
return response['data'][0]['url']
print(img_gen("$query"))
END
)
option=$(zenity --list --text="Choose an option:" --column=Options "View in browser" "Download" "New" "Exit")
while [ "$option" != "New" ]
do
if [ "$option" = "Exit" ]
then
exit 0
elif [ "$option" = "Download" ]
then
random_number=$(shuf -i 0-1000 -n 1)
filename="picgpt$random_number.png"
curl -o "$filename" "$url"
zenity --info --text="Image downloaded as $filename"
elif [ "$option" = "View in browser" ]
then
xdg-open "$url"
fi
option=$(zenity --list --text="Choose an option:" --column=Options "View in browser" "Download" "New" "Exit")
done
query=$(zenity --entry --text="Enter the desired keywords separated by a comma to generate the image, or type 'exit' to quit:")
done