Jump to content

Recommended Posts

Hey :)
 
I found a script that works for the upload and resize of images.
 
What's weird is that the upload/resize works for some JPG's (the screen impression) but not for some others (photoshop ones or the photos i took with my phone)
 
Fatal error: Function name must be a string in /home/a7805396/public_html/fxphoto.php on line 20
 
For another JPG, no error, the BDD uploads but the image doesn't resize/upload...
 
Here's my include fxphoto.php
 
<?php
    function creerImageDepuis($source) {
        $imageCreateFrom = array(
            "jpg" => "imagecreatefromjpeg",
            "png" => "imagecreatefrompng"
        );
 
        // Récupération de l'extention du fichier
        $extention = pathinfo($source, PATHINFO_EXTENSION);
        $extention = strtolower($extention);
        $extention = ($extention == "jpeg") ? "jpg" : $extention;
 
        $function = $imageCreateFrom[$extention];
        $image_source = $function($source);
 
        // Sauvegarde de la transparence de l'image
        imagealphablending($image_source, false);
        imagesavealpha($image_source, true);
 
        return $image_source;
    }
    
    function creerImage($image, $destination, $quality = 100) {
        $imageCreate = array(
            "jpg" => "imagejpeg",
            "png" => "imagepng"
        );
 
        // Récupération de l'extention du fichier
        $extention = pathinfo($destination, PATHINFO_EXTENSION);
        $extention = strtolower($extention);
 
        $function = $imageCreate[$extention];
 
        if ($extention == "jpg") {
            $function($image, $destination, $quality);
        } else {
            $function($image, $destination);
        }
 
        imagedestroy($image);
    }
    
    function redimensionneImage($source, $destination, $width, $height,
        $quality = 100){
        $image_source = creerImageDepuis($source);
 
        $size = getimagesize($source);
 
        if ($width == -1 || $height == -1) { // Si valeur automatique
            // On remplace le -1 par la valeur calculée
            $height = ($width != -1 && $height == -1) ?
                (($size[1] * $width) / $size[0]) : $height;
            $width = ($width == -1 && $height != -1) ?
                (($size[0] * $height) / $size[1]) : $width;
        } else if ($size[0] < $size[1]) { // Si portrait
            $tmp = $height;
            $height = $width;
            $width = $tmp;
        }
 
        $image_redim = @imagecreatetruecolor($width, $height);
        imagealphablending($image_redim, false);
        imagesavealpha($image_redim, true);
 
        imagecopyresampled ($image_redim, $image_source, 0, 0, 0, 0,
            $width, $height, $size[0], $size[1]);
 
        imagedestroy($image_source);
 
        creerImage($image_redim, $destination);
    }
?>

 

 

How can I fix that ?
 
Thanks
 
iSteelZ
 
PS : Sorry for the english and the variables names, I'm French
Edited by iSteelZ
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.