fraserreed/meme-puush 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

fraserreed/meme-puush

Composer 安装命令:

composer require fraserreed/meme-puush

包简介

Generate a meme to a local file, echo to the screen, or upload to puu.sh using their API

README 文档

README

Build Status Coverage Status

Meme generator using Imagick. Either output local file path, to screen or upload to Puu.sh using the Puu.sh API. Puu.sh API key required (http://puu.sh)

Installation

Install this package in your application using composer.

In the require section, add the following dependency:

"fraserreed/meme-puush": "~1.0"

Usage

First initialize the image object with an accessible URL to the image:

use MemePuush\Image;

$image = new Image( $img );

If the image path doesn't exist, an exception will be thrown when trying to output the meme image.

Next set the output format. The options are available in class constants of the Image class: Image::PUUSH (will upload the result using the Puu.sh api key), Image::FILE (will store the result locally and provide the output filename) and Image::SCREEN (will output the result to the browser).

$image->setOutputFormat( Image::PUUSH, '<puu.sh_api_key>' );

The puu.sh api key is not required if storing the result locally or outputting to the screen.

$image->setOutputFormat( Image::FILE );

Set the caption string, for the top caption or the bottom caption (or both):

$image->setTopCaption( "top caption text" );
$image->setBottomCaption( "bottom caption text" );

Finally output the result. What you do with the response is dependent on the format of the output:

$outputContent = $image->output();

switch( $output )
{
      case 'screen':
            header( 'Content-type: image/jpg' );
            echo file_get_contents( $outputContent );
            break;

      case 'file':
            echo $outputContent;
            break;

      case 'puush':
            echo json_encode( array( 'url' => $outputContent ) );
            break;
}

Example

A (really ugly) example UI for creating memes using the three available methods can be seen in public/index.php

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-04-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固