azlanali076/image-generator
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_STANDARDConstant for thestandardimage quality.ImageGenerator::QUALITY_HDConstant for thehdimage quality.ImageGenerator::STYLE_NATURALConstant for thenaturalimage style.ImageGenerator::STYLE_VIVIDConstant for thevividimage style.ImageGenerator::RESPONSE_FORMAT_URLConstant for theurlresponse format.ImageGenerator::RESPONSE_FORMAT_BASE64Constant for theb64_json(base 64) response format.
Parameters
string $promptThe text prompt for generating the image.int|null $widthThe width of the generated image (default is 1024 if null).int|null $heightThe height of the generated image (default is 1024 if null).string|null $qualityThe quality of the image (default is 'standard').string|null $styleThe style of the image (default is 'vivid').string|null $responseFormatThe format of the response (default is 'url').
Response Format
successA boolean indicating whether the request was successful.dataThe data returned from the API (includes the image URL if successful).messageAn error message if the request was not successful.codeAn error code if the request was not successful.
azlanali076/image-generator 适用场景与选型建议
azlanali076/image-generator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 07 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 azlanali076/image-generator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 azlanali076/image-generator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-07-23