• 목록
  • 아래로
  • 위로

PDF를 이미지 파일로 변경하는 모듈이 여러가지가 있지만 PDF2Image가 가장 널리 사용되는 것 같더군요 ^^

 

images = convert_from_path('/home/belval/example.pdf')

 

또는

 

images = convert_from_bytes(open('/home/belval/example.pdf', 'rb').read())

 

위와 같이 사용이 가능합니다.

 

 

 

아래와 같은 다양한 옵션이 가능합니다 ^^

 

convert_from_path(pdf_path, dpi=200, output_folder=None, first_page=None, last_page=None, fmt='ppm', jpegopt=None, thread_count=1, userpw=None, use_cropbox=False, strict=False, transparent=False, single_file=False, output_file=str(uuid.uuid4()), poppler_path=None, grayscale=False, size=None, paths_only=False, use_pdftocairo=False)

 

convert_from_bytes(pdf_file, dpi=200, output_folder=None, first_page=None, last_page=None, fmt='ppm', jpegopt=None, thread_count=1, userpw=None, use_cropbox=False, strict=False, transparent=False, single_file=False, output_file=str(uuid.uuid4()), poppler_path=None, grayscale=False, size=None, paths_only=False, use_pdftocairo=False)

 

 

파일 저장은 다음과 같이 할 수 있습니다.

 

for idx, img in enumerate(images):
    img.save('pdf_' + str(idx).zfill(len(str(len(images)))) + '.jpg', 'JPEG') # pdf_넘버링.jpg 이런 방식으로 네이밍을 합니다.

 

 

+)

Poppler를 설치해야 이 모듈을 제대로 사용할 수 있어요.

설치방법은 공홈에 있어요 ^^

설치 후에 poppler_path = '경로' 이런 방식으로 지정해줘야 되어요!

 

A python module that wraps the pdftoppm utility to convert PDF to PIL Image object - Belval/pdf2image

 

https://github.com/Belval/pdf2image

작성자
이니스프리 119 Lv. (0%) 1973520/115200000EXP

Make StudyForUs Great Again!

 

CSVpuymXAAAVVpd.jpg

댓글 0

권한이 없습니다.
번호 제목 글쓴이 날짜 조회 수
공지 [작업 완료] 설 명절 맞이 서버 업데이트 안내 3 마스터 마스터 24.02.11.17:21 968
공지 [중요] 호스팅 만료와 관련하여 일부 수칙이 변경됩니다. 4 마스터 마스터 23.01.14.02:23 4643
411 [Python] dictionary 자료형에서 setdefault와 update의 차이 이니스프리 이니스프리 20.04.05.18:12 199
410 [Python] Downloading Youtube Private Videos with Youtube_dlp - 유튜브 '비공개' 동영상 다운로드 이니스프리 이니스프리 23.06.30.20:05 308
409 [Python] extension이 標示되지 않는 online image의 extension을 알아내기 이니스프리 이니스프리 22.04.01.20:51 170
408 [Python] for 문에 두 개의 리스트를 넣고 enumerate를 사용하는 방법 이니스프리 이니스프리 21.05.01.21:01 219
407 [Python] Function to save list into a text file line by line 이니스프리 이니스프리 22.06.11.21:33 166
406 [Python] glob.glob() 정렬 방법 정리! 이니스프리 이니스프리 21.03.07.00:49 1507
405 [Python] Google_images_search 모듈 : 구글에서 이미지 검색 및 크롤링하기 이니스프리 이니스프리 21.09.21.18:03 308
404 [Python] How to send BOLD text with Telegram bot 이니스프리 이니스프리 23.08.10.19:51 212
403 [Python] HWP 파일 읽기 6 이니스프리 이니스프리 20.10.18.12:19 2092
402 [Python] ImportError: No module named '_curses' 에러에 대한 대처 방법 이니스프리 이니스프리 21.09.19.21:44 2808
401 [Python] Instalooter 에러 발생 시 대처법 1 이니스프리 이니스프리 21.01.31.13:37 215
400 [Python] json.load()와 json.loads()의 차이 2 이니스프리 이니스프리 21.01.24.13:15 495
399 [Python] m3u8 파일의 목록에 있는 ts 파일들을 merge하는 방법 6 이니스프리 이니스프리 20.06.20.22:03 1348
398 [Python] MP4 -> JPG thumbnail 生成 1 이니스프리 이니스프리 22.06.04.16:38 131
397 [Python] MP4 50% 進行된 frame을 JPG thumbnail로 生成 이니스프리 이니스프리 22.06.06.15:15 133
396 [Python] MP4 움짤을 clip하여 thumbnail 生成하기 이니스프리 이니스프리 22.06.09.08:35 173
395 [Python] Naver Login with requests 1 image Hanam09 Hanam09 21.07.17.01:48 2873
394 [Python] Ordered Set 이니스프리 이니스프리 23.09.19.20:24 195
393 [Python] OrderedDict에 대한 간단한 소개 3 이니스프리 이니스프리 20.06.16.13:09 163
[Python] PDF2Image 모듈 - PDF 파일을 이미지 파일로 변환 이니스프리 이니스프리 20.05.30.21:01 2772