일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 완전분산환경
- 하둡
- 설치
- nomount
- sql처리순서
- ORA-01034
- Kafka
- recovery
- 카프카 사용
- 하둡설치
- Standalone
- hadoop
- tibero
- 카프카
- window업데이트
- 하둡권한변경
- 에러
- initorcl
- 오라클복구
- sql연산자
- hadoop명령어
- oracle
- centos7
- 실습
- 결합연산자
- ORA-27101
- zookeeper
- crash recovery
- 오라클
- Linux
- Today
- Total
IT 꿈나무의 일상
Pixabay Developer API 이용하여 이미지 불러오기 본문
# Pixabay는 고화질의 이미지를 무료로 다운받아 사용할 수 있는 사이트 입니다.
원하는 키워드의 이미지나 동영상을 대량으로 다운받고 싶을때 Pixabay Developer API를 사용하여 간편하게 다운받을 수 있습니다.
1. 먼저 pixabay api를 이용할 수 있는 사이트에 들어갑니다.
https://pixabay.com/ko/service/about/api/
Pixabay Developer API
Pixabay Developer API Build something beautiful with the world's foremost collection of free high quality images and videos. Welcome to the Pixabay API, which gives you access to over 2.0 million photos, illustrations, vector graphics, and videos - for fre
pixabay.com
2. api를 이용하기 위해서는 KEY가 필요한데, 간편하게 로그인하여 무료로 key를 얻을 수 있습니다.

3. key를 사용하여 api를 사용해 보도록 하겠습니다.
- command 창에서 python-pixabay를 install 해줍니다.
pip install python-pixabay
// 임포트
from pixabay import Image, Video
//키입력
API_KEY = '본인 인증키'
- API_KEY가 제대로 작동하는지 확인해 봅니다.
# image operations
image = Image(API_KEY)
# default image search
image.search()
# custom image search
ims = image.search(q='yellow + flower',
lang='en',
image_type='photo',
orientation='horizontal',
category='animals',
safesearch='true',
order='latest',
page=2,
per_page=3)
q : 찾으려는 이미지 입니다. 생략하면 모든 이미지가 반환됩니다.
lang : 검색할 언어의 언어코드 입니다. 기본값은 'en' (영어) 입니다.
image_type : 이미지 유형을 필터링 합니다. "all", "photo", "illustration", "vector" 가 있습니다.
orientation : 이미지의 가로폭이 큰지 세로폭이 큰지 결정합니다. default 값은 "all'입니다.
category : 카테고리 별로 결과를 필터링 합니다. 허용되는 카테고리에는 backgrounds, fashion, nature, science, education, feelings, health, people, religion, places, animals, industry, computer, food, sports, transportation, travel, buildings, business, music 가 있습니다.
safesearch : 모든 연령대에 적합한 이미지를 반환할지말지를 나타냅니다. default값은 "false" 입니다.
order : 이미지 검색시 최신인지 인기순인지를 정렬합니다. default값은 "popular" 입니다.
page : 가져올 페이지의 수를 말합니다.
print(ims)
- 위 코드에 대한 응답은 다음과 같습니다.
{'total': 282, 'totalHits': 282, 'hits': [{'id': 5248678, 'pageURL': 'https://pixabay.com/es/photos/ojos-buscar-cara-ojo-gato-ni%C3%B1a-5248678/', 'type': 'photo', 'tags': 'ojos, buscar, cara', 'previewURL': 'https://cdn.pixabay.com/photo/2020/06/01/22/23/eyes-5248678_150.jpg', 'previewWidth': 150, 'previewHeight': 100, 'webformatURL': 'https://pixabay.com/get/53e2d14b4c55a414f1dc84609629307d1d38dfe5524c704c7c2b79d4944ec55c_640.jpg', 'webformatWidth': 640, 'webformatHeight': 427, 'largeImageURL': 'https://pixabay.com/get/53e2d14b4c55a414f6da8c7dda7936791637d9e453506c4870267fd6974ec658bc_1280.jpg', 'imageWidth': 5184, 'imageHeight': 3456, 'imageSize': 7722261, 'views': 28672, 'downloads': 23428, 'favorites': 103, 'likes': 121, 'comments': 22, 'user_id': 15567443, 'user': 'bniique', 'userImageURL': 'https://cdn.pixabay.com/user/2020/06/01/22-43-33-771_250x250.jpg'}, {'id': 5190341, 'pageURL': 'https://pixabay.com/es/photos/perro-animales-cachorro-mascota-5190341/', 'type': 'photo', 'tags': 'perro, animales, cachorro', 'previewURL': 'https://cdn.pixabay.com/photo/2020/05/19/11/27/dog-5190341_150.jpg', 'previewWidth': 150, 'previewHeight': 107, 'webformatURL': 'https://pixabay.com/get/53e1dc434956ad14f1dc84609629307d1d38dfe5524c704c7c2b79d4944ec55c_640.jpg', 'webformatWidth': 640, 'webformatHeight': 457, 'largeImageURL': 'https://pixabay.com/get/53e1dc434956ad14f6da8c7dda7936791637d9e453506c4870267fd6974ec658bc_1280.jpg', 'imageWidth': 3429, 'imageHeight': 2450, 'imageSize': 1804502, 'views': 345, 'downloads': 326, 'favorites': 0, 'likes': 1, 'comments': 0, 'user_id': 13001425, 'user': 'neovidio', 'userImageURL': 'https://cdn.pixabay.com/user/2019/07/10/14-10-33-254_250x250.jpg'}, {'id': 5167031, 'pageURL': 'https://pixabay.com/es/photos/buscar-que-es-hermosa-swan-5167031/', 'type': 'photo', 'tags': 'buscar, que, es', 'previewURL': 'https://cdn.pixabay.com/photo/2020/05/13/11/01/look-5167031_150.jpg', 'previewWidth': 150, 'previewHeight': 100, 'webformatURL': 'https://pixabay.com/get/53e1d3444a51ad14f1dc84609629307d1d38dfe5524c704c7c2b79d4944ec55c_640.jpg', 'webformatWidth': 640, 'webformatHeight': 427, 'largeImageURL': 'https://pixabay.com/get/53e1d3444a51ad14f6da8c7dda7936791637d9e453506c4870267fd6974ec658bc_1280.jpg', 'imageWidth': 7360, 'imageHeight': 4912, 'imageSize': 3863866, 'views': 455, 'downloads': 335, 'favorites': 10, 'likes': 8, 'comments': 2, 'user_id': 16515106, 'user': 'imranhussain1343431', 'userImageURL': 'https://cdn.pixabay.com/user/2020/05/12/17-45-24-402_250x250.jpeg'}]}
- API를 이용하여 이미지를 다운받아보겠습니다.
from pixabay import Image, Video
import pprint
import requests
import shutil
API_KEY = '본인 인증키'
image = Image(API_KEY)
j=1
for n in range(1,100):
ims = image.search(
q="sky",
lang="en",
image_type="all",
orientation="all",
category="background",
min_width=0,
min_height=0,
colors="",
editors_choice="false",
safesearch="false",
order="popular",
page=n,
per_page=200,
callback="",
pretty="true"
)
for i in range(0,200):
payload=ims['hits'][i]['largeImageURL']
resp = requests.get(payload, stream=True)
local_file = open(str(j)+"local_image.jpg", 'wb')
resp.raw.decode_content = True
shutil.copyfileobj(resp.raw, local_file)
del resp
print(str(j)+"URL of image: {}".format(payload))
j=j+1
** Pixabay의 API를 사용하는것은 강제성은 없지만 출처를 표시하는것을 권장하고 있습니다.
'IT 관련' 카테고리의 다른 글
kafka standalone으로 설치하기 (1) (0) | 2021.12.27 |
---|---|
Hadoop 완전분산모드로 설치하기 (3) - hadoop 사용법 (0) | 2021.08.13 |
Hadoop 완전분산모드로 설치하기 (2) (0) | 2021.04.04 |
Hadoop 완전 분산 모드로 설치하기 (1) (0) | 2021.03.01 |
CentOs 7에서 Oracle 12c 설치하기 (GUI 원격 설치) (0) | 2021.02.17 |