Beispiel #1
0
 /**
  * Internal function for cropping Jpg images.
  * @return Bool true or false depending on success or not.
  */
 function _cropJpg()
 {
     $source = ImagecreateFromJpeg($this->_source);
     $image = ImageCreateTrueColor($this->_width, $this->_height);
     ImageCopyResampled($image, $source, 0, 0, $this->_left, $this->_top, $this->_width, $this->_height, $this->_width, $this->_height);
     // this should set it to same file
     if ($this->_quality != "") {
         $result = ImageJpeg($image, $this->_target, $this->_quality);
     } else {
         $result = ImageJpeg($image, $this->_target);
     }
     ImageDestroy($image);
     ImageDestroy($source);
     return $result;
 }
Beispiel #2
0
 function _flipJpg()
 {
     $source = ImagecreateFromJpeg($this->_source);
     $width = imagesx($source);
     $height = imagesy($source);
     $image = ImageCreateTrueColor($width, $height);
     if ($this->_hori) {
         for ($i = 0; $i < $width; $i++) {
             ImageCopyResampled($image, $source, $width - $i - 1, 0, $i, 0, 1, $height, 1, $height);
         }
         if ($this->_vert) {
             ImageCopyResampled($source, $image, 0, 0, 0, 0, $width, $height, $width, $height);
         }
     }
     if ($this->_vert) {
         for ($i = 0; $i < $height; $i++) {
             ImageCopyResampled($image, $source, 0, $height - $i - 1, 0, $i, $width, 1, $width, 1);
         }
     }
     ImageDestroy($source);
     $result = ImageJpeg($image, $this->_target);
     ImageDestroy($image);
     return $result;
 }
function updateImageSizes()
{
    global $config;
    $query = 'SELECT * FROM kepek WHERE width IS NULL OR height IS NULL OR width = 0 OR height = 0 ';
    $result = mysql_query($query);
    while ($kep = mysql_fetch_array($result)) {
        $file = "kepek/templomok/" . $kep['tid'] . "/" . $kep['fajlnev'];
        if (file_exists($file)) {
            if (preg_match('/(jpg|jpeg)$/i', $file)) {
                $src_img = @ImagecreateFromJpeg($file);
                $kep['height'] = @imagesy($src_img);
                # original height
                $kep['width'] = @imagesx($src_img);
                # original width
                if ($kep['height'] != '' and $kep['width'] != '') {
                    $query = "UPDATE kepek SET height = '" . $kep['height'] . "', width = '" . $kep['width'] . "' WHERE id = " . $kep['id'] . " LIMIT 1";
                    if ($config['debug'] > 0) {
                        echo $query . "<br>";
                    }
                    mysql_query($query);
                }
            } else {
                if ($config['debug'] > 0) {
                    echo "A kép nem jpg: " . $file . "<br>";
                }
            }
        } else {
            if ($config['debug'] > 0) {
                echo "Hiányzó kép: " . $file . "<br>";
            }
        }
    }
}