• Stars
    star
    195
  • Rank 199,374 (Top 4 %)
  • Language
    PHP
  • License
    MIT License
  • Created over 13 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Image manipulation bundle for Symfony 2

Gregwar's ImageBundle

paypal

GregwarImageBundle provides easy Image manipulation and API for Symfony and Twig

If you use older version than Symfony 4, please use the 2.* version, else you can use 3.*.

Installation

Step 1: Download the GregwarImageBundle

Run the following composer command:

    composer req gregwar/image-bundle

Step 2: Configure the bundle and set up the directories

Adds the following configuration to your app/config/config.yml:

gregwar_image: ~

If you want to customize the cache directory name, you can specify it:

gregwar_image:
    cache_dir:  my_cache_dir

Creates the cache directory and change the permissions so the web server can write in it:

mkdir web/cache
chmod 777 web/cache

You can also enable the exception thrown if the given file does not exist:

gregwar_image:
    throw_exception: true

If you don't throw an exception, you can set the fallback_image, to set the image that should be rendered in this case:

gregwar_image:
    fallback_image: /path/to/your/fallback.jpg

If you have to change directories hierarchy or Web's name (e.g. web => public_html), you can set the web_dir to your new Web path:

gregwar_image:
    web_dir: %kernel.root_dir%/../../public_html

With Symfony Flex

With Symfony Flex architecture, you can create the config/packages/gregwar_image.yaml file with the following contents:

gregwar_image:
    web_dir: %kernel.root_dir%/../public

Usage

Basics

This bundle is based on the Gregwar's Image class and provides simple but powerful Twig extension. You can for instance use it this way:

<img src="{{ image('linux.jpg').resize(100,100).negate }}" />

And that's all ! The helper will automatically create the cached file on-the-fly if it doesn't exists yet.

The available methods are the same as the Gregwar's Image.

You can also use the logical file names for bundle resources :

<img src="{{ image('@AcmeDemoBundle/Resources/images/linux.jpg').resize(100,100).negate }}" />

If you use web_image() helper, the image file path will be prefixed by the web/ absolute directory of your application:

<!-- The image some/image.jpg will be prefixed by web directory prefix -->
<img src="{{ web_image('some/image.jpg').resize('10%') }}" />

Using Image API

The image instance provides also a simple API, you can call some methods to get informations about the handled image:

Image width: {{ image('linux.jpg').width }}px

Manipulating Image in Controllers

The Image Handler is accessible via a service called image.handling. So you can do in your controllers:

<?php
...
$this->get('image.handling')->open('linux.jpg')
    ->grayscale()
    ->rotate(12)
    ->save('out.jpg')

Requirements

GregwarImageBundle needs GD and exif extension for PHP to be installed on the web server

License

This bundle is under MIT license

More Repositories

1

Captcha

PHP Captcha library
PHP
1,717
star
2

Image

A PHP library to handle images
PHP
1,004
star
3

CaptchaBundle

Symfony bundle implementing a "captcha" form type
PHP
346
star
4

fatcat

FAT filesystems explore, extract, repair, and forensic tool
C++
301
star
5

blocks.js

JavaScript dataflow graph editor
JavaScript
215
star
6

Formidable

The PHP pragmatic forms library
PHP
120
star
7

Cache

A lightweight filesystem caching system
PHP
109
star
8

RST

PHP library to parse reStructuredText documents
PHP
93
star
9

notroot

Install APT packages without root access
Shell
80
star
10

Tex2png

PHP Library to generate PNGs from LaTeX math formula
PHP
71
star
11

ASCII-Tetris

ASCII Tetris game written in C
C
68
star
12

FormBundle

Provides the "entity_id" type (read "entity identifier")
PHP
64
star
13

Plankton

Plankton is a PHP pico framework
PHP
58
star
14

Mitm

Man in the middle tool
C
31
star
15

GnuPlot

A PHP Library for using GnuPlot
PHP
27
star
16

ArduiFlow

Arduino programming using flowchart environment
JavaScript
8
star
17

ArtNet-Console

A minimalist ArtNet-Console (Qt+libartnet)
C++
7
star
18

intro_ia

Jupyter Notebook
5
star
19

Tex2pngBundle

Symfony2 bundle to generate PNG images from LaTeX math formulas
PHP
4
star
20

CSV

CSV loader/saver
PHP
3
star
21

robotis-loader

Python program to flash robotis boards (OpenCM9.04, CM900)
Python
3
star
22

eFlute

Electronic flute
Eagle
3
star
23

FPDF

(Unofficial) FPDF Repository
PHP
3
star
24

PHP

Cours de PHP
PHP
2
star
25

orbita-placo

Python
2
star
26

MoveTheBox-solver

A simple solver for the MoveTheBox puzzle game
C
2
star
27

Slidey

The hybrid document & slide webapp builder
JavaScript
2
star
28

WebToApp-POC

This is a proof of concept on how a web application could communicate to a low level application using ZeroMQ
Objective-C
2
star
29

gregwar.github.io

HTML
2
star
30

Counter-Counter-Strike

Un simple programme C pour faire lagger les serveur CS sur le réseau local
2
star
31

avrel

AVR EmuLator (pedagogical)
C++
1
star
32

dfu-util

C
1
star
33

maple_mini_mbed

C
1
star
34

Configurations

Mes fichiers de configuration
Vim Script
1
star
35

td-dawin-2020

JavaScript
1
star
36

SlideySkeleton

Slidey skeleton project
PHP
1
star