All Projects → stefangabos → Zebra_image

stefangabos / Zebra_image

Licence: other
A compact (one-file only) and lightweight PHP library for image manipulation providing methods for performing several types of image manipulation operations and applying filters to images

Projects that are alternatives of or similar to Zebra image

Dali
Dali is an image blur library for Android. It contains several modules for static blurring, live blurring and animations.
Stars: ✭ 1,021 (+845.37%)
Mutual labels:  image-manipulation
Merge Images
Easily compose images together without messing around with canvas
Stars: ✭ 1,172 (+985.19%)
Mutual labels:  image-manipulation
Canvacord
Powerful image manipulation tool to manipulate images easily.
Stars: ✭ 87 (-19.44%)
Mutual labels:  image-manipulation
Mopaint
🎨💪 Modern, modular paint and more! (pre-alpha, not much done yet)
Stars: ✭ 50 (-53.7%)
Mutual labels:  image-manipulation
Dna Gan
DNA-GAN: Learning Disentangled Representations from Multi-Attribute Images
Stars: ✭ 65 (-39.81%)
Mutual labels:  image-manipulation
Pixelsorter
Pixel sorting tool for Python
Stars: ✭ 73 (-32.41%)
Mutual labels:  image-manipulation
Imagene
A General Purpose Image Manipulation Tool
Stars: ✭ 36 (-66.67%)
Mutual labels:  image-manipulation
Glitch This
📷 Glitchify images and GIF - with highly customizable options!
Stars: ✭ 1,396 (+1192.59%)
Mutual labels:  image-manipulation
Pix2pix
Image-to-image translation with conditional adversarial nets
Stars: ✭ 8,765 (+8015.74%)
Mutual labels:  image-manipulation
Panoramic Image Stitching Using Invariant Features
Given a number of input images, concatenate all images to produce a panoramic image using invariant features.
Stars: ✭ 81 (-25%)
Mutual labels:  image-manipulation
Realismcnn
code for predicting and improving visual realism in composite images
Stars: ✭ 53 (-50.93%)
Mutual labels:  image-manipulation
Popbot
Color splash effects using Deep Learning
Stars: ✭ 61 (-43.52%)
Mutual labels:  image-manipulation
Cloudinary Vue
Cloudinary components library for Vue.js application, for image and video optimization.
Stars: ✭ 76 (-29.63%)
Mutual labels:  image-manipulation
Nimp
Nimp - Node-based image manipulation program.
Stars: ✭ 45 (-58.33%)
Mutual labels:  image-manipulation
Lggan
[CVPR 2020] Local Class-Specific and Global Image-Level Generative Adversarial Networks for Semantic-Guided Scene Generation
Stars: ✭ 97 (-10.19%)
Mutual labels:  image-manipulation
Bringing Old Photos Back To Life
Bringing Old Photo Back to Life (CVPR 2020 oral)
Stars: ✭ 9,525 (+8719.44%)
Mutual labels:  image-manipulation
Imageviewer
HDR, PFM, DDS, KTX, EXR, PNG, JPG, BMP image viewer and manipulator
Stars: ✭ 71 (-34.26%)
Mutual labels:  image-manipulation
Neural Doodle
Turn your two-bit doodles into fine artworks with deep neural networks, generate seamless textures from photos, transfer style from one image to another, perform example-based upscaling, but wait... there's more! (An implementation of Semantic Style Transfer.)
Stars: ✭ 9,680 (+8862.96%)
Mutual labels:  image-manipulation
Exprgan
Facial Expression Editing with Controllable Expression Intensity
Stars: ✭ 98 (-9.26%)
Mutual labels:  image-manipulation
Svelte Easy Crop
A Svelte component to crop images with easy interactions
Stars: ✭ 80 (-25.93%)
Mutual labels:  image-manipulation
zebrajs

Zebra_Image

A compact (one-file only) and lightweight PHP library for image manipulation providing methods for performing several types of image manipulation operations and applying filters to images.

Latest Stable Version Total Downloads Monthly Downloads Daily Downloads License

Use Zebra_Image to resize, flip, rotate, crop and sharpen images. The library supports loading and saving images in the GIF, JPEG, PNG and WEBP formats and preserves transparency of GIF, PNG8, PNG24 and WEBP images and it doesn't require any external libraries other than the GD2 extension (with which PHP usually comes pre-compiled with).

All the filters supported by PHP can be applied to images. These filters include negate, grayscale, brightness, contrast, colorize, edgedetect, emboss, gaussian blur, selective blur, mean removal, smooth and pixelate. Multiple filters can be applied at once for creating custom filters.

The code is heavily commented and generates no warnings/errors/notices when PHP's error reporting level is set to E_ALL.

Using this library you can resize images to exact given width and height and still maintain aspect ratio by using one of the following methods:

  • the image will be scaled so that it will fit in a box with the given width and height and then it will be centered both horizontally and vertically in the box. The blank area will be filled with a specified color.

  • the image will be scaled so that it could fit in a box with the given width and height but will not be enclosed in a box with given width and height

  • after the image has been scaled so that its width and height are equal or greater than the required width and height respectively, a region of required width and height will be cropped from the top left corner of the resulted image.

  • after the image has been scaled so that its width and height are equal or greater than the required width and height respectively, a region of required width and height will be cropped from the center of the resulted image.

Here are the results of resizing a 800×573 pixels image to a 200×200 pixels image and preserving the aspect ratio by using each of the aforementioned methods:

Zebra_Image Method 1
After the image is resized to 200x143 pixels representing the size of the image that would fit in a 200x200 pixels box while preserving its aspect ratio, it is centered both horizontally and vertically in a 200x200 pixels box. In our example the background is white but it can be set to any color. The resulting image has 200x200 pixels.
Zebra_Image
Method 2
The image is resized to 200x143 pixels representing the size of the image that would fit in a 200200 pixels box while preserving its aspect ratio.
Zebra_Image
Method 3 & 4
Step 1: The image is first resized to 279x200 pixels representing the size closest to the required size where the image's width and height are both equal or greater than the required width and height respectively, while preserving its aspect ratio.
Zebra_Image
Step 2: A 200x200 pixels area will be cropped from the top-left corner of the image (for method 3) or from the center of the image (for method 4). Zebra_Image

Support the development of this library

Your support means a lot and keeps me motivated to keep this project alive. If you like this project please ⭐️ it by clicking on the star button at the top of the page. Thank you!

Donate

Features

  • can be used to resize, flip, rotate, crop and sharpen images
  • all the filters supported by PHP can be applied to images: negate, grayscale, brightness, contrast, colorize, edgedetect, emboss, gaussian blur, selective blur, mean removal, smooth and pixelate; multiple filters can be applied at once for creating custom filters;
  • images can be resized to exact sizes and maintaining aspect ratio by automatically cropping them
  • preserves transparency of GIF, PNG8, PNG24 and WEBP images
  • supports creation of interlaced JPEG images
  • code is heavily commented and generates no warnings/errors/notices when PHP's error reporting level is set to E_ALL
  • can automatically fix incorrect image orientation
  • has awesome documentation

Requirements

PHP 5+, bundled GD 2.0.28+ (PHP 7.0.0+ for WEBP support)

PHP needs to be compiled with --enable-exif (Windows users enable php_mbstring.dll and php_exif.dll extensions in php.ini) for auto-fixing image rotation so images are always shown correctly regardless of how the camera was held when the pictures were taken.

Installation

You can install Zebra_Image via Composer

# get the latest stable release
composer require stefangabos/zebra_image

# get the latest commit
composer require stefangabos/zebra_image:dev-master

Or you can install it manually by downloading the latest version, unpacking it, and then including it in your project

<?php

require_once 'Zebra_Image.php';

How to use

<?php

// load the image manipulation class
require 'path/to/Zebra_Image.php';

// create a new instance of the class
$image = new Zebra_Image();

// if you handle image uploads from users and you have enabled exif-support with --enable-exif
// (or, on a Windows machine you have enabled php_mbstring.dll and php_exif.dll in php.ini)
// set this property to TRUE in order to fix rotation so you always see images in correct position
$image->auto_handle_exif_orientation = false;

// indicate a source image (a GIF, PNG, JPEG or WEBP file)
$image->source_path = 'path/to/image.png';

// indicate a target image
// note that there's no extra property to set in order to specify the target
// image's type -simply by writing '.jpg' as extension will instruct the script
// to create a 'jpg' file
$image->target_path = 'path/to/image.jpg';

// since in this example we're going to have a jpeg file, let's set the output
// image's quality
$image->jpeg_quality = 100;

// some additional properties that can be set
// read about them in the documentation
$image->preserve_aspect_ratio = true;
$image->enlarge_smaller_images = true;
$image->preserve_time = true;
$image->handle_exif_orientation_tag = true;

// resize the image to exactly 100x100 pixels by using the "crop from center" method
// (read more in the overview section or in the documentation)
//  and if there is an error, check what the error is about
if (!$image->resize(100, 100, ZEBRA_IMAGE_CROP_CENTER)) {

    // if there was an error, let's see what the error is about
    switch ($image->error) {

        case 1:
            echo 'Source file could not be found!';
            break;
        case 2:
            echo 'Source file is not readable!';
            break;
        case 3:
            echo 'Could not write target file!';
            break;
        case 4:
            echo 'Unsupported source file format!';
            break;
        case 5:
            echo 'Unsupported target file format!';
            break;
        case 6:
            echo 'GD library version does not support target file format!';
            break;
        case 7:
            echo 'GD library is not installed!';
            break;
        case 8:
            echo '"chmod" command is disabled via configuration!';
            break;
        case 9:
            echo '"exif_read_data" function is not available';
            break;

    }

// if no errors
} else echo 'Success!';

📚 Check out the awesome documentation!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].