curl -X POST https://jpghd.com/api/img_upload \
-H 'X-API-KEY: YOUR_API_KEY' \
-d 'filename=small.jpg' \
-d 'filetype=image/jpeg'
# Use url from the response to upload the file to R2.
curl -X PUT --upload-file small.jpg \
-H 'Content-Type: image/jpeg' \
'UPLOAD_URL'import requests
filename = 'small.jpg'
filetype = 'image/jpeg'
r = requests.post(
url='https://jpghd.com/api/img_upload',
headers={'X-API-KEY': 'YOUR_API_KEY'},
data={'filename': filename, 'filetype': filetype}
)
upload = r.json()
with open(filename, 'rb') as image:
requests.put(
url=upload['url'],
data=image,
headers={'Content-Type': filetype}
)
print(upload['fileurl'])
- APIキーでこのエンドポイントを呼び出し、一時的なR2アップロードURLと公開画像URLを取得します
- 同じContent-TypeでPUTしてファイルをアップロードし、fileurlを拡大APIのinputに使用します
curl -d '{"style": "photo_mid", "scratch": "", "color": "", "input": "YOUR_IMAGE_URL"}' \
-H 'X-API-KEY: YOUR_API_KEY' \
https://jpghd.com/api/task/
import requests
import json
data = {
'style': 'photo_mid',
'scratch': '',
'color': '',
'input': 'YOUR_IMAGE_URL'
}
r = requests.post(
url='https://jpghd.com/api/task/',
headers={'X-API-KEY': 'YOUR_API_KEY'},
data=json.dumps(data)
)
print(r.json())
- data is JSON format
- style can by photo(Photo AI Enhance + Lossless Enlarge 4X), photo_mid(Photo AI Enhance + Lossless Enlarge 2X), photo_slim(Photo AI Enhance), art(Artwork Image AI Enhance + Lossless Enlarge 4X), art_mid(Artwork Image AI Enhance + Lossless Enlarge 2X), art_slim(Artwork Image AI Enhance)
- scratch is Optional,set empty string will not repair scratch
- color is Optional, set empty string will not colorize the photo
- livephoto is Optional, set empty string will not make magic photo
- return status can be ok(means successed), conf_param_error(means conf parameter errors), exceed_limit(means api credits not enough)
curl https://jpghd.com/api/task/tid,tid,tidimport requests
r = requests.get(url='https://jpghd.com/api/task/tid,tid,tid')
print(r.json())
- yellow part is the task id returned by the Task Create API,split by comma
curl -X POST https://jpghd.com/api/task/tid,tid,tidimport requests
r = requests.post(url='https://jpghd.com/api/task/tid,tid,tid')
print(r.json())
- yellow part is the task id returned by the Task Create API,split by comma