Giter Site home page Giter Site logo

class.images.php's People

Contributors

creativecat avatar markhowellsmead avatar sprain avatar webbird 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

class.images.php's Issues

Missing: Set coordinates for cropping

Currently, when cropping a image, you always start at 0|0. Would be great if you could add the additional option to crop a different area.
Something like:

public function resize(
    $max_width,
    $max_height,
    $method="fit",
    $cropAreaLeftRight="c",
    $cropAreaBottomTop="c",
    $jpgQuality=75,
    $dst_x=0,
    $dst_y=0
) {

You could also check if is_numeric($cropAreaLeftRight) and is_numeric($cropAreaBottomTop) and when they are both numeric use those values for positioning the cropping area.

Color loss after resize()

Hi I'm experiencing a strange issue with color loss when I use this class. See my examples. Image on the left is the original (in the attachment also) and on the right after re-sizing. As you can see there is a big difference here. What do you think?

Thanks

26855463-5
colour difference

Watermark transparency

We discussed this on your HP some time ago. I maybe have a solution. Try this code:


public function writeWatermark($opacity=50, $marginH=0, $marginV=0, $positionWatermarkLeftRight="c", $positionWatermarkTopBottom="c"){

    //Watermark
    list($image_create_func, $image_save_func) = $this->Watermark->getFunctionNames();
    $watermark = $image_create_func($this->Watermark->getImage());

    //get base image
    list($image_create_func, $image_save_func) = $this->getFunctionNames();
    $baseImage = $image_create_func($this->image);

    imagealphablending($baseImage, true);
    imagesavealpha($baseImage, true);

    imagealphablending($watermark, true);
    imagesavealpha($watermark, true);

    // resize the watermark to fit original image size
    //imagecopy( $baseImage, $watermark, 0, 0, 0, 0, imagesx($watermark), imagesy($watermark));
    imagecopyresampled( $baseImage, $watermark, 0, 0, 0, 0, imagesx($baseImage), imagesy($baseImage), imagesx($watermark), imagesy($watermark));

    //Set image
    if(!$image_save_func($baseImage, $this->tmpfile)){
        throw new Exception("Cannot save file ".$this->tmpfile);
    }//if

    //Set new main image
    $this->setNewMainImage($this->tmpfile);

    //Free memory!
    imagedestroy($baseImage);
    unset($Watermark);

}//function

I tried this with PNG and JPG as base image and PNG as watermark image. It also resizes the watermark to fit the base image size. I've still got to do some testing, but maybe you'd like to check this meanwhile.

watermark quality

at writeWatermark function, with current stock function watermark image has bad quality, but base image is good. This is fix:

instead

        //Set image
        if(!$image_save_func($baseImage, $this->tmpfile)){
            throw new Exception("Cannot save file ".$this->tmpfile);
        }

I replaced with

        //Set image
		$img_quality = '';
        if($image_save_func == "ImageJPEG"){ $img_quality = 100; }
		if($image_save_func == 'ImagePNG'){ $img_quality = 9; }
		
        if(!$image_save_func($baseImage, $this->tmpfile, $img_quality)){
            throw new Exception("Cannot save file ".$this->tmpfile);
        }

Now watermark is good quality. Only I dont know how will it work with gif

PNG transparency

Heute habe ich ein Problem mit transparenten PNGs entdeckt – nach dem Bearbeiten mit deiner Klasse hatten die Bilder alle einen schwarzen Hintergrund. Wahrscheinlich ist das zwar nicht der perfekte Bugfix, aber durch den folgenden Block in Zeile 248 (im “//Let’s get it on, create image!” Block nach der ersten Zeile eingefügt) wird das Problem gelöst:

if ($image_save_func == “ImagePNG”) {
imagesavealpha($imageC, true);
$trans_colour = imagecolorallocatealpha($imageC, 0, 0, 0, 127);
imagefill($imageC, 0, 0, $trans_colour);
}

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.