承接 azlanali076/image-generator 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

azlanali076/image-generator

最新稳定版本:1.0.1

Composer 安装命令:

composer require azlanali076/image-generator

包简介

A Laravel package for generating images using the OpenAI API. This package provides an easy-to-use interface for interacting with the OpenAI API to generate images based on text prompts.

README 文档

README

A Laravel package for generating images using the OpenAI API. This package provides an easy-to-use interface for interacting with the OpenAI API to generate images based on text prompts.

Installation

You can install the package via Composer:

composer require azlanali076/image-generator

Configuration

1. Publish the Configuration File

Publish the configuration file to your application's config directory:

php artisan vendor:publish --provider="Azlanali076\ImageGenerator\ImageGeneratorServiceProvider"

2. Set Up Your API Key

Make sure to add your API key to your .env file:

OPENAI_API_KEY=your-openai-api-key

Usage

You can use the package by calling the generate method on the facade ImageGenerator.

use Azlanali076\ImageGenerator\Facades\ImageGenerator;

// Generate an image
$imageResponse = ImageGenerator::generate(
    "A Cute White Cat"
);

// Check if the response is successful
if ($imageResponse['success']) {
    // Retrieve the image URL
    $url = $imageResponse['data'][0]['url'];
    echo "Image URL: " . $url;
} else {
    // Handle the error
    echo "Error: " . $imageResponse['message'];
}

Constants

  • ImageGenerator::QUALITY_STANDARD Constant for the standard image quality.
  • ImageGenerator::QUALITY_HD Constant for the hd image quality.
  • ImageGenerator::STYLE_NATURAL Constant for the natural image style.
  • ImageGenerator::STYLE_VIVID Constant for the vivid image style.
  • ImageGenerator::RESPONSE_FORMAT_URL Constant for the url response format.
  • ImageGenerator::RESPONSE_FORMAT_BASE64 Constant for the b64_json (base 64) response format.

Parameters

  • string $prompt The text prompt for generating the image.
  • int|null $width The width of the generated image (default is 1024 if null).
  • int|null $height The height of the generated image (default is 1024 if null).
  • string|null $quality The quality of the image (default is 'standard').
  • string|null $style The style of the image (default is 'vivid').
  • string|null $responseFormat The format of the response (default is 'url').

Response Format

  • success A boolean indicating whether the request was successful.
  • data The data returned from the API (includes the image URL if successful).
  • message An error message if the request was not successful.
  • code An error code if the request was not successful.

统计信息

  • 总下载量: 9
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-07-23