Giter Club home page Giter Club logo

php-image-resize's People

Contributors

adityapatadia avatar andydune avatar cainmi avatar denx-b avatar diegomarty avatar dreammeup avatar droeftoeter avatar ecrider avatar eigan avatar emiliodeg avatar erigoni avatar felipetnh avatar funivan avatar gabrieleolmi avatar gpaton avatar gronostajo avatar hugoseabra avatar hultberg avatar jaynakrani avatar jgullstr avatar jonkiddy avatar kraffix avatar lefuturiste avatar noisytoken avatar pastou avatar peter279k avatar petrwl avatar pluc avatar romanzaycev avatar them1984 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  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

php-image-resize's Issues

What license is your PHP image resize class?

I would like to use your great class in our commercial product, but I cannot find your licensed defined anywhere.
If no license is defined, the normal copyright (All rights reserved) comes into action and anybody - no matter if the usage is private or commercial - has to ask you.

So may I ask you if I can use it for our commercial product or set it generally under a license you prefer?

Thanks in advance and keep up your great work!

how to use this plugin?

i didn't get your documentation how to start? do you have any video tutorial or examples?

webp support

You might want to add webp as an output format, GD supports it since php 5.5.

Bigger png size after resizing

Hello!
When you resizing png with transparent background - it is important to maintain small file size.
For example:

  • original image.png (350x700px 76 KB)
  • resized image.png (265x535px 200KB)

It happens because of increasing amount of colors in palette. Under 1000 in original image / more than 8000 in resized.

Fast dirty hack to avoid it:
$image_type = $image_type ?: $this->source_type;
if($image_type == IMAGETYPE_PNG) {
$dest_image = imagecreate($this->getDestWidth(), $this->getDestHeight()); // not true color!
$alpha = imagecolorallocatealpha($dest_image, 255, 255, 255, 127); // fully transparent white color
imagefill($dest_image, 0, 0, $alpha); // fill image with transparent background
} else {
$dest_image = imagecreatetruecolor($this->getDestWidth(), $this->getDestHeight());
}

  • resized image.png without true color (265x535px 56KB)

Maybe you will implement some sort of feature, based on this.

Version 1.3

Hey guys (especially @adityapatadia),

I've just pushed up a bunch of commits related to the changes we discussed in #19.

It was meant to be a new PR, but accidentally just pushed it to master.

Should be pretty stable though, and still getting passing all tests with 100% CC.

But please let me know if we need to change anything before tagging.

Majority of API stays the same, just the new createFromString() from @Sjaakmoes, which has been simplified a bit.

Fatal error: Uncaught Eventviva\ImageResize

I run into an very strange problem.

I have an upload script, that will be start through the form from the upload page. So, this script runs "stand alone". Then I have an import area in my project. This import is included into an other (main) file.

When I upload an file, everything is fine. ImageResize do what it should do.

When I import the images, I got this error message:

`
Fatal error: Uncaught Eventviva\ImageResize
Exception: Could not read file in /home/sites/dev/admin/classes/ImageResize.php:32

Stack trace:
#0 /home/sites/dev/admin/content_photo_import.php(130): Eventviva\ImageResize->__construct('/home/sites/dev...')
#1 /home/sites/dev/admin/dashboard.php(57): include('/home/sites/dev...')
#2 /home/sites/dev/admin/index.php(48): include('/home/sites/dev...')
#3 {main} thrown in /home/sites/dev/admin/classes/ImageResize.php on line 32
`

The path's are in both cases the same. The only different is, on the upload script I use "move_uploaded_file($tmp, $newFilePath" and on the import script, I use "copy($file, $newFilePath".

Any idea how to fix?

Regards
Torsten

how to destroy & reuse image variable?

thank you for this script & your hard work.

i am using your script in a php loop with an array of images to be uploaded and resize

since for each image, i will use the same variable

$image = new \Eventviva\ImageResize("$image_src");
(where $image_src is an image source which is run in php loop)

your script will not run on the next image. I am thinking it is because the $image is not being cleared for a new source

i tried:
$image = "";
unset($image);
and destroy($image)

but none of these work. How do i destroy & reuse the variable for a new image source?

quality_jpg doesn't work

i use quality_jpg to 10, but doesn't work

my code :

<?php
$image = new \Eventviva\ImageResize('img1.jpg');
$image->quality_jpg = 10;
$image->resize(215, 290);
$image->save('img2.jpg');
?>

Resize work, but not quality.

Compress to "x" MegaBytes

Hi there,

Is there any way to compress the image setting, for example, as max file size 5 MB instead of setting quality parameter?

Thanks in advance

Cannot read file

I have the following error message in firebug when I upload the photos, it works fine locally

Fatal error: Uncaught exception 'Exception' with message 'Could not read file' in /home/sites/wightwarriors
.co/public_html/tapesup/include/ImageResize.php:68
Stack trace:
#0 /home/sites/wightwarriors.co/public_html/tapesup/photos/upload.php(42): Eventviva\ImageResize->__construct

('http://www.wigh...')
#1 {main}

thrown in /home/sites/wightwarriors.co/public_html/tapesup/include/ImageResize.php on line 68

File size 0 when quality set

I am loading and sizing images, however if I specify quality the image gets a file size of 0. This happens when I use $image->quality_png = 50; and $image->save($tmp_name, IMAGETYPE_PNG, 50);

But the images export fine with out setting a quality.

My code:

$image = new \Eventviva\ImageResize($_FILES['file']['tmp_name']);

$image->resizeToBestFit($image_size[0], $image_size[0]);

$image->save($tmp_name, IMAGETYPE_PNG, 50);

Greyscale image

Hey, thanks for an awesome package!

Is there the ability to greyscale an image? If not, could it be a possible enhancement?

Thanks!

[FEATURE REQUEST] PSR Standards

I'd like to see this library get updated to utilize PSR standards.

One major thing I've noticed is that part of the library utilizes tab characters and others utilize 4 space indentation.

If I get a little free time, I will happily take a look at updating all of the variables, method definitions, spaces, etc... and put in a PR. I just want to know if there is any support for this from the maintainers. 1 or 2 thumbs up will be enough for me to put this on my "to-do" list.

Fatal error: Uncaught exception 'Exception' with message 'Could not read file' in

eventviva/php-image-resize: 1.6.1

Fatal error:  Uncaught exception 'Exception' with message 'Could not read file' in D:\xampp\htdocs
\folder\vendor\eventviva\php-image-resize\lib\ImageResize.php:68

#0: Eventviva\ImageResize-&gt;__construct('')
#2: call_user_func_array(Array, Array)

thrown in <b>D:\xampp\htdocs\folder\vendor\eventviva\php-image-resize\lib\ImageResize.php on line 68

Try upload this img http://www.letsgodigital.org/images/producten/1830/testrapport/alpha-test-photo.jpg

require ROOT . '/vendor/autoload.php';
$tempImg = $_FILES['file']['tmp_name'];
$image= new \Eventviva\ImageResize($tempImg );
$image->quality_jpg = 60;
$image->save($dir . $imgName, IMAGETYPE_JPEG)

Watermark support

Some thoughts about support an watermark ? Could I do pull request ?

File does not exist

I get the following error:
Fatal error:
Uncaught exception 'Eventviva\ImageResizeException' with message 'File does not exist' in /home/mysite/public_html/inc/imageresize.php:72
Stack trace:
#0 /home/mysite/public_html/inc/savephotos.php(54): Eventviva\ImageResize->__construct('')
#1 /home/mysite/public_html/my-details/mydetails/myhome/photosandpanoramas.php(17): include('/home/mysite/pu...')
#2 {main} thrown in /home/mysite/public_html/inc/imageresize.php on line 72

This only appears with larger files - I am testing with an image 3.5M, which will be resized after uploading. I followed up with a 708k file which uploaded without issue.

Users can upload up to 8 images, and sometime use files as large as 6 or 7Mb, so the server is set to
post_max_size 70M
upload_max_filesize 8M

I understand that the file may be in a different place to the expected place - but I can't see how to find what the filename currently is, or where it should be! And, if a smaller file gets through, then I think that is less likely to be the issue.

Caching

The class looks fine. It would be a benefit to have a caching feature. It could be based on a CONST save_path. If it is set, it can check if the image exists. If it does, directly return the image.
Optional: A no_cache on the API request in case of new settings for the same dimensions while maintaining a save_path.

It would greatly expand on projects this class could be used for.

JPG results in unspecified error

When I upload a jpg using the class my site errors and goes to a blank screen (no error message). The class works fine on my local dev environment, it only breaks on the remote host, and only then when uploading jpgs.

Size of PNG too big after resize

Hi,

I've tried to resize PNG image to the smaller size (with resizeToWidth) but the resulting image was extremely big. When I've used image compress tool (ImageOptim) it was able to remove 99% of the image size so there must be too much bloating information in the image.

resizeToWidth() and Height seems to not resize above original dimension

$image = ImageResize::createFromString( file_get_contents( $data['thumb'] ) ) ) {
$full = $image->resizeToWidth( 800 )->crop( 800, 420 )->getImageAsString( IMAGETYPE_JPEG, 100 );

Above code creates an image that is identical to the original. the original size is around 480px, the image is never scaled up and also not cut. is there some some of issue if the image is smaller than the resize to width?

Memory Limit Error and Error Suppression

This is a great tool, thanks for developing this module.

I have encountered some bugs however. I hope it would improve the current code base. I noticed in one of the recent commits - errors are suppressed. However, there are other areas of the code where errors need to be suppressed.

I have added the setting below. However, I do understand that errors are useful in development (not production!) settings.

ini_set ('gd.jpeg_ignore_warning', 1);

I also encountered an memory limit specifically related to the following code block. The imagerotate function bugs out when the memory limit exceeds 94371840 bytes. So I have also included the setting below.

ini_set('memory_limit', '300M'); // add this

if ($orientation === 6 || $orientation === 5){
        $img = imagerotate($img, 270, null);

...

Perhaps this module could include some sort of logic around these two cases. Most PHP frameworks provide an environment variable, perhaps this can be hooked in somewhere.

PHP Fatal error: Uncaught Error: Call to undefined function Eventviva\imagecreatefrom*

Hello, trying to us your library but every file fails to resizewith an error like the following, happening with both png and jpeg images

[Mon Jan  8 11:15:26 2018] PHP Fatal error:  Uncaught Error: Call to undefined function Eventviva\imagecreatefrompng() in /php/ImageResize.php:112
Stack trace:
#0 /upload.php(48): Eventviva\ImageResize->__construct('/tmp/phpV0fAfB')
#1 {main}
  thrown in /php/ImageResize.php on line 112
[Mon Jan  8 11:15:26 2018] 192.168.1.149:33896 [500]: /upload.php - Uncaught Error: Call to undefined function Eventviva\imagecreatefrompng() in /php/ImageResize.php:112
Stack trace:
#0 /upload.php(48): Eventviva\ImageResize->__construct('/tmp/phpV0fAfB')
#1 {main}
  thrown in /php/ImageResize.php on line 112

is this a bug or am I doing something wrong?

Image is saving but gif animation not working

$image = ImageResize::createFromString(base64_decode('base64_GIF_Image_Data'));
$image->resize(500, 500);
$image->save('image.gif', IMAGETYPE_GIF);

GIF not working
Image is saving but animation not working

500 Internal Server Error

Hi all,

I hope you re all fine .
I need help to use your library.
I don't user composer so I do as you mentioned :

" ...
Otherwise:
include '/path/to/ImageResize.php';
Because this class uses namespacing, when instantiating the object, you need to either use the fully qualified namespace:
$image = new \Eventviva\ImageResize();
..."

At this line I get a 500 Internal Server Error :
$image = new \Eventviva\ImageResize();
OR when I alias it
use \Eventviva\ImageResize;
$image = new ImageResize(); <--- this line

I included this way:

include "../../../includes/imageResize/lib/ImageResize.php";
use \Eventviva\ImageResize;

Is the something I missed ?

Thank you in advance for your answer.

IMAGETYPE_* on save() method seems to replace all "png" occurrences in the filename

My entry filename was "p18mq5j9k2op6amc1pngp1u1da37.png" and after I started

$image_object->save(p18mq5j9k2op6amc1pngp1u1da37.png, IMAGETYPE_JPEG,90);

filename turned to "p18mq5j9k2op6amc1jpgp1u1da37.jpg". Notice that there are two replacements in filename. I supposed that save() method can replace only the extension part of the filename.

How can I fix this issue?

Algorithm

Which algorithm(s) are used for the resampling / interpolation?
Bicubic, bilinear, nearest neighbour, etc.?
Is it possible to change it?

IMAGETYPE_WEBP is not recognized

I am trying to add webp image file type like

elseif ($this->image_type == IMAGETYPE_WEBP) {
 $this->image = imagecreatefrompng($filename);
}

but it gives me error. could anyone tell me how to add webp file type?

Problem with transparent PNG

I'm having issues to generate a thumbnail from a Transparent PNG.
Someone have some idea how to solve this problem?

Add Animated GIF Support

Firstly, Just want to say I love this package. Its simple and does exactly what I need without having to worry about anything.

The only thing that I have noticed is that with using this package it take away any animation from a gif. Is there any plan to support animated gifs in the future?

Ability to crop in random position

Hi

Thank you for a nice resizing tool. Would be great if you are able crop the image at a random position, i.e a method like this:

public function crop($width, $height, $source_x, $source_y) {}

This will make this tool compatible with this client side cropping script: http://www.croppic.net/

Improve saving to string

The function getImageAsString saves the image to a temporary file on disk, just to read it again. This is not optimal. You can get the result in a string by using output buffering.

<?php
ob_start();
imagepng($image);
$image_data = ob_get_contents();
ob_end_clean();

[Feature] Determine aspect on max width and/or height

I'm developing an application where the image has to have a max width or max height. This way it will always be scaled correctly. Now I can enforce a width and height but it won't keep the aspect ratio.

Since I do not know in advance what the aspect ratio of the image is I cannot determine how the image should be scaled.

Lets say I have a frame that is 145w and 90h (maximum dimensions). If i use resize it will force the image in this frame, rather than computing how much it should remove on either one dimension.

File could not be found

when i try to instanciate a new ResizeImage object i got this error. "The file eventviva\imageresize.php could not be found."

Resize animated GIF file without destroying animation

I am trying to resize a gif file but animation is destroyed.

<?php

require 'vendor/autoload.php';

$image = new \Eventviva\ImageResize("img/1460392243.gif");

var_dump($image);

$image->resizeToBestFit(500, 300);
$image->save("img/" . time().".gif");

?>

Please help !

Suppress exif_read_data() errors

exif_read_data() can sometimes generate errors and should be suppressed. The same suggestion is made in a comment to the SE post that served as inspiration for the imageCreateJpegfromExif() method.

substandard for psr-2

    /**
     * Gets crop position (X or Y) according to the given position
     *
     * @param integer $expectedSize
     * @param integer $position
     * @return integer
     */
    protected function getCropPosition($expectedSize, $position = self::CROPCENTER)
    {
        $size = 0;
        switch ($position) {
        case self::CROPBOTTOM:
        case self::CROPRIGHT:
            $size = $expectedSize;
            break;
        case self::CROPCENTER:
        case self::CROPCENTRE:
            $size = $expectedSize / 2;
            break;
        case self::CROPTOPCENTER:
            $size = $expectedSize / 4;
            break;
        }
        return $size;
    }

image

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.