PowerPoint를 사용하면 프레젠테이션에서 다양한 유형의 슬라이드 배경을 설정할 수 있습니다. 예를 들어 이미지, 단색 등을 배경으로 설정할 수 있습니다. 이 기사에서는 Python에서 PowerPoint PPT 슬라이드의 배경을 설정하는 방법을 보여줍니다. 프로그래밍 방식으로 이미지, 색상 또는 그라디언트로 PPT 슬라이드의 배경을 채우는 방법을 명시적으로 다룹니다.

PowerPoint에서 슬라이드 배경을 설정하는 Python 라이브러리

Aspose.Slides for Python은 PowerPoint 프레젠테이션을 만들고 조작할 수 있는 인기 있고 기능이 풍부한 라이브러리입니다. 이 라이브러리를 사용하여 PowerPoint 프레젠테이션에서 슬라이드 배경을 설정합니다. PyPI에서 라이브러리를 설치하려면 다음 명령을 사용할 수 있습니다.

> pip install aspose.slides

Python에서 이미지를 PPT 슬라이드 배경으로 설정

다음은 Python에서 PowerPoint PPT/PPTX 슬라이드의 배경 이미지를 설정하는 단계입니다.

  • 먼저 Presentation 클래스를 사용하여 PPT/PPTX 프레젠테이션을 로드하거나 만듭니다.
  • 그런 다음 Presentation.slides 컬렉션에서 원하는 슬라이드의 참조를 가져옵니다.
  • 슬라이드 배경의 채우기 유형을 FillType.PICTURE로 설정합니다.
  • 그림의 채우기 모드를 PictureFillMode.STRETCH로 설정합니다.
  • Presentation.images.add\image() 메서드를 사용하여 프레젠테이션 컬렉션에 이미지를 추가합니다.
  • Slide.background.fill\format.picture\fill\format.picture.image 속성을 사용하여 슬라이드의 배경 이미지를 설정합니다.
  • 마지막으로 Presentation.save(string, SaveFormat) 메서드를 사용하여 업데이트된 프레젠테이션을 저장합니다.

다음 코드 샘플은 Python에서 PowerPoint PPT 슬라이드의 배경 이미지를 설정하는 방법을 보여줍니다.

import aspose.slides as slides
import aspose.pydrawing as drawing

# Create or load presentation
with slides.Presentation() as pres:
    # Set the background with Image
    pres.slides[0].background.type = slides.BackgroundType.OWN_BACKGROUND
    pres.slides[0].background.fill_format.fill_type = slides.FillType.PICTURE
    pres.slides[0].background.fill_format.picture_fill_format.picture_fill_mode = slides.PictureFillMode.STRETCH

    # Set the picture
    img = drawing.Bitmap("Tulips.jpg")

    # Add image to presentation's images collection
    imgx = pres.images.add_image(img)

    pres.slides[0].background.fill_format.picture_fill_format.picture.image = imgx

    # Save presentation
    pres.save("set-slide-background-image.pptx", slides.export.SaveFormat.PPTX)

다음 스크린샷은 배경 이미지를 추가한 후 결과 PPT 슬라이드를 보여줍니다.

Python에서 이미지를 PPT 슬라이드 배경으로 설정

Python에서 PPT 슬라이드의 배경색 설정

다음은 Python을 사용하여 PowerPoint PPT에서 슬라이드의 배경색을 설정하는 단계입니다.

  • 먼저 Presentation 클래스를 사용하여 PowerPoint PPT/PPTX를 로드하거나 만듭니다.
  • 슬라이드 배경의 채우기 유형을 FillType.SOLID로 설정합니다.
  • 그런 다음 Slide.background.fill\format.solid\fill\color.color 속성을 사용하여 슬라이드의 배경색을 설정합니다.
  • 마지막으로 Presentation.save(string, SaveFormat) 메서드를 사용하여 업데이트된 프레젠테이션을 저장합니다.

다음 코드 샘플은 Python에서 PPT 슬라이드의 배경색을 설정하는 방법을 보여줍니다.

import aspose.slides as slides
import aspose.pydrawing as drawing

# Create or load presentation
with slides.Presentation() as pres:
    # Set the background color of the first slide
    pres.slides[0].background.type = slides.BackgroundType.OWN_BACKGROUND
    pres.slides[0].background.fill_format.fill_type = slides.FillType.SOLID
    pres.slides[0].background.fill_format.solid_fill_color.color = drawing.Color.blue

    # Save presentation
    pres.save("set-slide-background-gradient.pptx", slides.export.SaveFormat.PPTX)

Python에서 마스터 슬라이드의 배경색 설정

프레젠테이션의 모든 슬라이드에 적용할 마스터 슬라이드의 배경도 설정할 수 있습니다. 다음은 Python에서 마스터 슬라이드의 배경색을 변경하는 단계입니다.

  • 먼저 Presentation 클래스를 사용하여 PowerPoint PPT/PPTX를 로드하거나 만듭니다.
  • 마스터 슬라이드 배경의 채우기 유형을 FillType.SOLID로 설정합니다.
  • 그런 다음 MasterSlide.background.fill\format.solid\fill\color.color 속성을 사용하여 마스터 슬라이드의 배경색을 설정합니다.
  • 마지막으로 Presentation.save(string, SaveFormat) 메서드를 사용하여 업데이트된 프레젠테이션을 저장합니다.

다음 코드 샘플은 PowerPoint PPT에서 마스터 슬라이드의 배경색을 변경하는 방법을 보여줍니다.

import aspose.slides as slides
import aspose.pydrawing as drawing

# Create or load presentation
with slides.Presentation() as pres:
    # Set the background color of the master slide
    pres.masters[0].background.type = slides.BackgroundType.OWN_BACKGROUND
    pres.masters[0].background.fill_format.fill_type = slides.FillType.SOLID
    pres.masters[0].background.fill_format.solid_fill_color.color = drawing.Color.forest_green

    # Save presentation
    pres.save("set-master-slide-background-color.pptx", slides.export.SaveFormat.PPTX)

Python에서 그라디언트를 PPT 슬라이드 배경으로 설정

아래 단계에서 설명한 것처럼 Python용 Aspose.Slides를 사용하여 PPT 슬라이드의 그라데이션 배경을 설정할 수도 있습니다.

  • 먼저 Presentation 클래스를 사용하여 PowerPoint PPT/PPTX를 로드하거나 만듭니다.
  • 슬라이드 배경의 채우기 유형을 FillType.GRADIENT로 설정합니다.
  • 그런 다음 Slide.background.fill\format.gradient\format.tile\flip 속성을 사용하여 배경 그라데이션 형식을 설정합니다.
  • 마지막으로 Presentation.save(string, SaveFormat) 메서드를 사용하여 업데이트된 프레젠테이션을 저장합니다.

다음 코드 샘플은 Python에서 PPT 슬라이드의 그라데이션 배경을 설정하는 방법을 보여줍니다.

import aspose.slides as slides

# Create or load presentation
with slides.Presentation() as pres:
    # Apply gradiant effect to the background
    pres.slides[0].background.type = slides.BackgroundType.OWN_BACKGROUND
    pres.slides[0].background.fill_format.fill_type = slides.FillType.GRADIENT
    pres.slides[0].background.fill_format.gradient_format.tile_flip = slides.TileFlip.FLIP_BOTH

    # Save presentation
    pres.save("set-slide-background-color.pptx", slides.export.SaveFormat.PPTX)

다음 스크린샷은 슬라이드의 그라데이션 배경을 보여줍니다.

Python에서 슬라이드의 그라데이션 배경색 설정

무료 API 라이선스 받기

임시 라이선스를 요청하면 Python용 Aspose.Slides를 평가 제한 없이 사용할 수 있습니다.

결론

이 기사에서는 Python을 사용하여 PowerPoint PPT에서 슬라이드의 배경색 또는 이미지를 설정하는 방법을 배웠습니다. 또한 PowerPoint 프레젠테이션에서 일반 또는 마스터 슬라이드의 그라데이션 배경을 설정하는 방법을 살펴보았습니다. 문서를 방문하여 Python용 Aspose.Slides의 다른 기능을 탐색할 수 있습니다. 또한 포럼을 통해 문의 사항을 자유롭게 알려주세요.

또한보십시오