GithubHelp home page GithubHelp logo

stefangabos / zebra_image Goto Github PK

View Code? Open in Web Editor NEW
139.0 139.0 51.0 460 KB

A single-file lightweight PHP library designed for efficient image manipulation featuring methods for modifying images and applying filters

Home Page: https://stefangabos.github.io/Zebra_Image/Zebra_Image/Zebra_Image.html

License: Other

PHP 99.91% Batchfile 0.09%
crop gd-library image image-manipulation php php-image php-image-processor resize resize-images

zebra_image's People

Contributors

geekwright avatar stefangabos avatar userlond avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zebra_image's Issues

error deprecated with php7

Hi,

I tried with php 7 on Joomla! 3.5 and got an error.
Do you know and will there be an update?
The use of Zebra_Image is a part in JEM -Joomlaeventmanager. And I like it.

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Zebra_Image has a deprecated constructor in /srv/www/vhosts/mysite.ch/httpdocs/components/com_jem/classes/Zebra_Image.php on line 46

Crop Images by Circle

I need to crop image with Circle shape not Square. Is there any way to do this with Zebra Image Library?

Animated WEBP images throw exception

Zebra_image.php:1523 imagecreatefromwebp() fails when loading an animated webp image.
It throws this exception: ErrorException: gd-webp cannot allocate temporary buffer

It has nothing to do with any buffer. It just seems to be not implemented into libgd at the moment.

Maybe a fix is to add a ZebraImage error saying that libgd does not currently support this?

This seems to be a good function to check if a webp image is animated:
https://stackoverflow.com/a/61242086

Sources:
libgd/libgd#648
https://bugs.php.net/bug.php?id=79809&thanks=4
https://www.php.net/manual/en/function.imagecreatefromwebp.php

I might pick this up myself but wanted to create the issue first.

Release 2.3.0 is not in Packagist

Composer does not pick up on the 2.3.0 release.

There were changes in how applications interact with GitHub recently. Usually packagist will offer to fix things if you sign in to packagist.org and check your packages.

php 8.1.12 - imagecolorsforindex Argument #2 ($color) is out of range

Zebra version: "stefangabos/zebra_image": "^2.8"
PHP Version 8.1.12
GD Version | bundled (2.1.0 compatible)

Zebra_Image stops executing on some gif images on my site. It fails hard so I have to add a try catch around the Zebra code. No image is generated.

The error is: imagecolorsforindex Argument #2 ($color) is out of range
Line: 1491

$this->source_transparent_color = @imagecolorsforindex($identifier, $this->source_transparent_color_index);

Seems like source_transparent_color_index is greater than the total number of colors in the image.

Similiar errors and solutions:
Stackoverflow
ProcessWire

If I change line 1491 to this it works.

if ($this->source_transparent_color_index <= imagecolorstotal($identifier)) { $this->source_transparent_color = @imagecolorsforindex($identifier, $this->source_transparent_color_index); }

Example gif:
300x300-nophoto

Undefined variable $arguments...

I'm getting this warning:

Notice: Undefined variable: arguments in .../vendor/stefangabos/zebra_image/Zebra_Image.php on line 429.

I've seen i don't have the filter installed, but the variable should be defined.

Edit: just to help, i tried to use 'gausian_blur' filter.

Edit 2: Zebra docs is wrong, the correct is 'gaussian_blur' not 'gausian_blur' that's how a got the error. Even so, the warning shoudn't happen.

Chrome

Hey

i have the problem that the example of you works on FireFox but not on chrome is this a well known issue or is has it something to do with my browser

Resize Mode Doesn't Work in PHP 8.1

All resize mode except ZEBRA_IMAGE_BOXED and ZEBRA_IMAGE_NOT_BOXED and ZEBRA_IMAGE_CROP_TOPLEFT (obviously) doesn't work as intented, they all start cropping from top left just like ZEBRA_IMAGE_CROP_TOPLEFT

using this test code in PHP 8.1 environment

<?php
require "Zebra_Image.php";

$mode = [ZEBRA_IMAGE_BOXED,
		ZEBRA_IMAGE_NOT_BOXED,
		ZEBRA_IMAGE_CROP_TOPLEFT,
		ZEBRA_IMAGE_CROP_TOPCENTER,
                ZEBRA_IMAGE_CROP_TOPRIGHT,
                ZEBRA_IMAGE_CROP_MIDDLELEFT,
                ZEBRA_IMAGE_CROP_CENTER,
                ZEBRA_IMAGE_CROP_MIDDLERIGHT,
                ZEBRA_IMAGE_CROP_BOTTOMLEFT,
                ZEBRA_IMAGE_CROP_BOTTOMCENTER,
                ZEBRA_IMAGE_CROP_BOTTOMRIGHT];
		
function saveImage($mode)
{
	$image = new Zebra_Image(); 
	$image->source_path = 'test.jpg';
	$image->target_path = 'test-thumb-'.$mode.'.jpg';
	$image->jpeg_quality = 60;
	$image->preserve_aspect_ratio = true;
	$image->enlarge_smaller_images = true;        
	$image->preserve_time = true;
	$image->handle_exif_orientation_tag = true;
	$image->sharpen = true;
	$image->jpeg_interlace = true;        
	$image->resize(200, 200, $mode);
        
	return $image->error;
}

echo '<img src="test.jpg" /><br />';
foreach ($mode as $m) {
	saveImage($m);	
        echo '<img src="test-thumb-'.$m.'.jpg" />';
}
?>

Gaussian Blur level

Hello,

Is it possible to set a blur level when applying the 'gaussian blur' filter?

Regards,

Composer package code mismatch even if version is the same as GitHub

Version 2.8.1 tagged on GitHub, also version 2.8.1 tagged on Packagist, yet the Packagist version suffers from the WEBP animation detection bug:

LINE 1536: case IMAGETYPE_WEBP:

                    // because animated WEBP images are not supported
                    // we need to check if this is such a file
                    // WEBP file header https://developers.google.com/speed/webp/docs/riff_container
                    // solution from by Sven Liivak https://stackoverflow.com/questions/45190469/how-to-identify-whether-webp-image-is-static-or-animated#answer-52333192

                    $fh = fopen($this->source_path, 'rb');

                    // let's see if this is the "Extended" file format
                    fseek($fh, 12);

                    // if this is the extended file format
                    if (fread($fh, 4) === 'VP8X') {

                        // look for the "Animation (A)" bit
LINE 1552:              fseek($fh, 16); <----------------------------------- should be 20, not 16

                        // is this is an animated WEBP?
                        $is_animated = ((ord(fread($fh, 1)) >> 1) & 1);

                    }

resized png's do not retain alpha

resizing a png image with an alpha background does not preserve transparency ?
577320da52881

I am trying to overlay this in FFMPEG - it may well be that it requires png colortype=6 ?

Manipulate stream instead of files

Could be good to manipulate the picture directly from there stream value, in order to allow the write and read to other tool like gaufrette.

Where are the definitions for IMG_FILTER_*

I can't apply any filters because the filters are not defined anywhere. It aways throws an error because the filters are not defined anywhere in the file. Can't find IMG_FILTER_GAUSIAN_BLUR... Was the filter functionality removed?

Rotate image

Hi,

Nice lib, I have a small problem when sending an image to resize, he spins it, how to avoid?

PHP Warning exif_read_data(): File not supported

If auto_handle_exif_orientation is true one gets a warning if file is e.g. a GIF image. This is because only JPEG and TIFF are supported by exif_read_data().

This could be prevented by changing line 1349 from if ($this->auto_handle_exif_orientation)
to if ($this->auto_handle_exif_orientation && ($this->source_type === IMAGETYPE_JPEG))
(because TIFF is not supported by Zebra_Image)

Cropped image black borders

Is it possible to set the background color if the cropped result is outside the image?
Now it gets a black border.
I only see a definition in the resize method but not at the cropping.

No filter applied

Hello!
I'm uploading a file to the server and I want filters to be applied to this file, but I can't.
Can anyone help me?
P.S. I don't speak English and I'm just starting to learn php

`<?php
require 'Zebra_Image.php';
//$auto_handle_exif_orientation = true;
$my_file = $_FILES['filename']['name'];
$uploadfile = basename($_FILES['filename']['name']);

if (move_uploaded_file($_FILES['filename']['tmp_name'], $uploadfile)) {
$image = imagecreatefrompng($uploadfile);
$image = new Zebra_Image();
$image->apply_filter(array(
array('grayscale'),
array('emboss'),
));
header('content-type: image/png');
//imagepng($image);
//imagedestroy($image);
echo $image;
} else {
echo "Error upload file!";
}
?>`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.