PHP Photo Instagram filters
Simple class to create a filters similar like Instagram filters
This is sample output:
In one project I needed to create simple filters in images and because I love instagram, I inspired here.
Finally, I wrote a simple class in PHP that adjusts the picture and creates a filter
How to use?
Usage is very simple:
create source data from image
– select the filter and apply it on the picture
– send image to output
Objective-C
1 2 3 4 5 6 7 8 9 10 11 12 |
//load class include 'filters/effects.php'; //create image from jpeg $image = imagecreatefromjpeg("space.jpg"); //create instance of Effects class. Class adjust image data $effects = new Effects($image, Effects::GRAY); //send image to output header("content-type: image/png"); imagepng($image); imagedestroy($image); |
Similarly, we proceed if we need to save the image:
Objective-C
1 2 3 4 5 6 7 8 9 10 |
//load class include 'filters/effects.php'; //create image from jpeg $image = imagecreatefromjpeg("space.jpg"); //create new image with filter $out_image = clone $image; new Effects($out_image, Effects::GRAY); imagejpeg($out_image, 'newimagename.jpg'); |
Class with examples of use can be found on GitHub https://github…PHP-Instagram-effects.
Posted on 19 August 2013
Thank you!
I do not know why but I’m getting this error:
Fatal error: __clone method called on non-object in /…/public_html/filters/boost.php on line 10
This code:
<?php
//load class
include 'filters/effects.php';
//create image from jpeg
$image = imagecreatefromjpeg("space.jpg");
//create new image with filter
$out_image = clone $image;
new Effects($out_image, Effects::GRAY);
imagejpeg($out_image, '../uptest/newimagename.jpg');
You can’t clone GD resource
What can i do with it?
you can only copy this variable:
$image = imagecreatefromjpeg(“space.jpg”);
$out_image = $image;
or maybe:
http://stackoverflow.com/questions/12605768/how-to-clone-a-gd-resource-in-php
OK Thank you!
Great Class, I need one feature Valencia, could you please help on this.