Skip to content

Commit

Permalink
Merge pull request #1 from lohanidamodar/feat-utopia-image
Browse files Browse the repository at this point in the history
extracting image library
  • Loading branch information
eldadfux authored Feb 19, 2021
2 parents 1e8e381 + 382d3d5 commit 66e38db
Show file tree
Hide file tree
Showing 21 changed files with 4,539 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/vendor/
/.vscode/
.phpunit.result.cache
30 changes: 30 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
dist: xenial

arch:
- amd64

os: linux

language: shell

notifications:
email:
- team@appwrite.io

services:
- docker

before_install:
- curl -fsSL https://get.docker.com | sh
- echo '{"experimental":"enabled"}' | sudo tee /etc/docker/daemon.json
- mkdir -p $HOME/.docker
- echo '{"experimental":"enabled"}' | sudo tee $HOME/.docker/config.json
- sudo service docker start
- docker --version
- docker buildx create --use

install:
- docker-compose build

script:
- docker-compose up
42 changes: 42 additions & 0 deletions Dockerfile-php7
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM composer:2.0 as step0

WORKDIR /src/

COPY ./composer.json /src/
COPY ./composer.lock /src/

RUN composer update --ignore-platform-reqs --optimize-autoloader \
--no-plugins --no-scripts --prefer-dist

FROM php:7.4-cli-alpine as final

LABEL maintainer="team@appwrite.io"

RUN \
apk update \
&& apk add --no-cache --virtual .deps \
make \
automake \
autoconf \
gcc \
g++ \
&& apk add --no-cache \
libstdc++ \
imagemagick \
imagemagick-dev \
&& pecl install imagick \
&& docker-php-ext-enable imagick \
&& apk del .deps \
&& rm -rf /var/cache/apk/*

WORKDIR /code

COPY --from=step0 /src/vendor /code/vendor

# Add Source Code
COPY ./tests /code/tests
COPY ./src /code/src
COPY ./phpunit.xml /code/phpunit.xml
COPY ./psalm.xml /code/psalm.xml

CMD [ "sh", "-c", "/code/vendor/bin/phpunit --verbose --configuration /code/phpunit.xml && /code/vendor/bin/psalm --show-info=true" ]
67 changes: 67 additions & 0 deletions Dockerfile-php8
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
FROM composer:2.0 as step0

WORKDIR /src/

COPY composer.lock /src/
COPY composer.json /src/

RUN composer update --ignore-platform-reqs --optimize-autoloader \
--no-plugins --no-scripts --prefer-dist

FROM php:8.0-cli-alpine as step1

ENV PHP_IMAGICK_VERSION=master

RUN \
apk add --no-cache --virtual .deps \
make \
automake \
autoconf \
gcc \
g++ \
git \
imagemagick \
imagemagick-dev


RUN \
## Imagick Extension
git clone https://github.com/Imagick/imagick && \
cd imagick && \
git checkout $PHP_IMAGICK_VERSION && \
phpize && \
./configure && \
make && make install

FROM php:8.0-cli-alpine as final

LABEL maintainer="team@appwrite.io"

RUN \
apk update \
&& apk add --no-cache --virtual .deps \
make \
automake \
autoconf \
gcc \
g++ \
&& apk add --no-cache \
libstdc++ \
imagemagick \
&& apk del .deps \
&& rm -rf /var/cache/apk/*

WORKDIR /code

COPY --from=step0 /src/vendor /code/vendor
COPY --from=step1 /usr/local/lib/php/extensions/no-debug-non-zts-20200930/imagick.so /usr/local/lib/php/extensions/no-debug-non-zts-20200930/

# Add Source Code
COPY ./tests /code/tests
COPY ./src /code/src
COPY ./phpunit.xml /code/phpunit.xml
COPY ./psalm.xml /code/psalm.xml

RUN echo extension=imagick.so >> /usr/local/etc/php/conf.d/imagick.ini

CMD [ "sh", "-c", "/code/vendor/bin/phpunit --verbose --configuration /code/phpunit.xml && /code/vendor/bin/psalm --show-info=true" ]
45 changes: 43 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,43 @@
# image
Lite & fast micro PHP library for creating common image manipulations that is **easy to use**.
# Utopia Image

[![Build Status](https://travis-ci.org/utopia-php/ab.svg?branch=master)](https://travis-ci.com/utopia-php/image)
![Total Downloads](https://img.shields.io/packagist/dt/utopia-php/image.svg)
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord)](https://appwrite.io/discord)

Utopia Image library isLite & fast micro PHP library for creating common image manipulations that is **easy to use**. This library is maintained by the [Appwrite team](https://appwrite.io).


## Getting Started

Install using composer:
```bash
composer require utopia-php/image
```

```php
<?php

require_once '../vendor/autoload.php';

use Utopia\Image\Image;
$image = new Image(\file_get_contents('image.jpg'));
$target = 'image_100x100.jpg';
$image->crop(100, 100);
$image->save($target, 'jpg', 100);

```

## System Requirements

Utopia Image requires PHP 7.4 or later. We recommend using the latest PHP version whenever possible.

## Authors

**Damodar Lohani**

+ [https://twitter.com/lohanidamodar](https://twitter.com/lohanidamodar)
+ [https://github.com/lohanidamodar](https://github.com/lohanidamodar)

## Copyright and license

The MIT License (MIT) [http://www.opensource.org/licenses/mit-license.php](http://www.opensource.org/licenses/mit-license.php)
26 changes: 26 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "utopia-php/image",
"description": "A simple Image manipulation library",
"type": "library",
"keywords": ["php","framework","upf","utopia","image"],
"license": "MIT",
"authors": [
{
"name": "Eldad Fux",
"email": "eldad@appwrite.io"
}
],
"autoload": {
"psr-4": {"Utopia\\Image\\":"src/Image"}
},
"require": {
"php": ">=7.4",
"chillerlan/php-qrcode": "4.3.0",
"ext-imagick": "*"
},
"require-dev": {
"phpunit/phpunit": "^9.3",
"vimeo/psalm": "4.0.1"
},
"minimum-stability": "dev"
}
Loading

0 comments on commit 66e38db

Please sign in to comment.