generateSocialMediaImage()

in genai-for-marketing/frontend/src/app/social-media-post/social-media-post.component.ts [182:210]


  generateSocialMediaImage() {
    this.images =[];
    if (this.promptVal === "") {
      alert('please enter context value')
    } else {
      this.showProgress = true
      let obj = {
        "prompt": "Theme:" + this.selectedCampaignFromDropdown[0].data.theme + " " + this.promptVal 
        + ", Aspect Ration: " + this.socialMediaForm.controls.aspectRation.value 
        + ", Color Tone:" + this.socialMediaForm.controls.colorTone.value
        + ", Lighting:" + this.socialMediaForm.controls.lighting.value 
        + ", Composition:" + this.socialMediaForm.controls.compostion.value 
        + ", Content Type:" + this.socialMediaForm.controls.contentType.value,
        "number_of_images": 3,
        "negative_prompt": ""
      }
      this.socialmediaService.generateImage(obj).subscribe((res: any) => {
        res.generated_images.forEach((element: { images_base64_string: string; id: any }) => {
          this.imageRes = this.domSanitizer.bypassSecurityTrustResourceUrl('data:image/jpg;base64,'
            + element.images_base64_string);
          this.images.push({ id: element.id, image: this.imageRes });
          this.showImageSection = true;
          this.showProgress = false;
          this.showImageGenarateBtn = true;
          this.generateSocialMediaPosts()
        });
      });
    }
  }