yusufshakeel/dyreimage-php

此包的最新版本(v1.1.2)没有提供许可证信息。

这是一个图像缩放项目。

v1.1.2 2018-04-18 17:23 UTC

This package is not auto-updated.

Last update: 2024-09-20 07:38:46 UTC


README

这是一个图像缩放项目。

状态

license Build Status npm version Bower

文档

点击此处查看文档。

入门

  • 下载最新版本。
  • 克隆仓库:git clone https://github.com/yusufshakeel/dyreimage-php.git
  • 使用Bower安装:bower install dyreimage-php
  • 使用npm安装:npm install dyreimage-php
  • 使用composer安装:composer require yusufshakeel/dyreimage-php

要求

DYReImage需要以下内容

  • PHP版本5.5或更高。
  • GD扩展。

简要历史

我在2014年上大学时在做图像处理项目。当时创建了此项目,然后决定进行一些更改并上传到GitHub。

包含内容

dyreimage-php/
├── image/
│   └── sample.jpeg
├── src/
│   └── DYReImage/
│       ├── Core/
│       │   ├── Config.php
│       │   ├── Helper.php
│       │   └── Validator.php
│       ├── Utilities/
│       │   ├── Image.php
│       │   └── Resize.php
│       ├── autoload.php
│       └── DYReImage.php
├── tests/
└── index.php

如何使用?

将位于src目录中的DYReImage目录包含到您的项目中。现在要开始使用,请编写以下代码。

<?php
require_once 'path/to/DYReImage/autoload.php';

// path of source image file that we want to resize
$source = 'path/to/image/sample.jpeg';

// path of destination image file
// resized image will be saved in img directory by the name output.png
$destination = 'path/to/destination/img/output.png';

// options to resize image
// required image width = 400, height 200 (in pixels) and quality = 80
$option = array(
  "height" => 200,
  "width" => 400,
  "quality" => 80
);

// resize
try {
  $obj = new DYReImage\DYReImage($source, $destination, $option);
  $obj->resize();
} catch(\Exception $e) {
  die("Error: " . $e->getMessage());
}
?>

注意!您必须具有写入权限才能将缩放后的图像保存到目标目录。

创建灰度图像

require_once 'path/to/DYReImage/autoload.php';

$source = 'path/to/image/sample.jpg';
$destination = 'path/to/image/output.png';
$option = array(
	"quality" => 80
);

try {
	$obj = new DYReImage\DYReImage($source, $destination, $option);
	$obj->grayscaleImage();
} catch(\Exception $e) {
	die("Error: " . $e->getMessage());
}

创建红色图像

require_once 'path/to/DYReImage/autoload.php';

$source = 'path/to/image/sample.jpg';
$destination = 'path/to/image/output.png';
$option = array(
	"quality" => 80
);

try {
	$obj = new DYReImage\DYReImage($source, $destination, $option);
	$obj->redImage();
} catch(\Exception $e) {
	die("Error: " . $e->getMessage());
}

创建绿色图像

require_once 'path/to/DYReImage/autoload.php';

$source = 'path/to/image/sample.jpg';
$destination = 'path/to/image/output.png';
$option = array(
	"quality" => 80
);

try {
	$obj = new DYReImage\DYReImage($source, $destination, $option);
	$obj->greenImage();
} catch(\Exception $e) {
	die("Error: " . $e->getMessage());
}

创建蓝色图像

require_once 'path/to/DYReImage/autoload.php';

$source = 'path/to/image/sample.jpg';
$destination = 'path/to/image/output.png';
$option = array(
	"quality" => 80
);

try {
	$obj = new DYReImage\DYReImage($source, $destination, $option);
	$obj->blueImage();
} catch(\Exception $e) {
	die("Error: " . $e->getMessage());
}

许可证

它是免费的,并使用MIT许可证发布,版权所有(c)2017 Yusuf Shakeel

请我喝杯茶

如果您喜欢观看我的YouTube视频,并且在这里的GitHub项目中发现我的项目有趣且有帮助,那么请随意请我喝杯茶或咖啡。这有助于创建更多 :)

通过PayPal捐赠