Example #1
0
function bilder($width, $height, $dest)
{
    if (!function_exists("imagick_readimage")) {
        echo "Imagick-Extention nicht installiert";
        return false;
    }
    $handle = imagick_readimage("./tmp/tmp.file_org");
    if (!$handle) {
        $reason = imagick_failedreason($handle);
        print "Lesen: {$reason}<BR>\n";
        flush();
        return false;
    }
    if (!imagick_resize($handle, $width, $height, IMAGICK_FILTER_UNKNOWN, 0)) {
        $reason = imagick_failedreason($handle);
        print "Resize: {$reason}<BR>\n";
        flush();
        return false;
    }
    if (!imagick_writeimage($handle, "./tmp/tmp.file_{$dest}")) {
        $reason = imagick_failedreason($handle);
        print "Schreiben: {$reason}<BR>\n";
        flush();
        return false;
    }
    return true;
}
 function __construct($image, $isfile = false)
 {
     if ($isfile) {
         $blob = imagick_readimage($image);
         parent::__construct($blob, false);
     } else {
         parent::__construct($image, false);
         $this->data = imagick_blob2image($image);
     }
 }
 public function open($path, $mimetype = null)
 {
     if ($mimetype === null) {
         $this->mime = ImageMagickGD::getFileType($path);
     } else {
         $this->mime = $mimetype;
     }
     $this->img = imagick_readimage($path);
     if ($this->img) {
         imagick_set_image_quality($this->img, 100);
         return true;
     }
     return false;
 }
Example #4
0
 function _load_data()
 {
     if (!$this->loaded) {
         if (!empty($this->filename)) {
             $this->data = imagick_readimage($this->filename);
             $this->loaded = true;
         } elseif (!empty($this->data)) {
             $this->data = imagick_blob2image($this->data);
             $this->loaded = true;
         }
         if ($this->loaded && ($t = imagick_failedreason($this->data))) {
             $this->data = NULL;
         }
     }
 }
Example #5
0
 /**
  * Loads an image
  *
  * @param string $image filename
  * @return bool|PEAR_Error TRUE or a PEAR_Error object on error
  * @access public
  */
 function load($image)
 {
     if (!($this->imageHandle = imagick_readimage($image))) {
         $this->free();
         return $this->raiseError('Couldn\'t load image.', IMAGE_TRANSFORM_ERROR_IO);
     }
     if (imagick_iserror($this->imageHandle)) {
         return $this->raiseError('Couldn\'t load image.', IMAGE_TRANSFORM_ERROR_IO);
     }
     $this->image = $image;
     $result = $this->_get_image_details($image);
     if (PEAR::isError($result)) {
         return $result;
     }
     return true;
 }
Example #6
0
function submit_photo()
{
    $dir = "../images";
    $pid = intval(get_http_var('pid'));
    $errors = array();
    if (!array_key_exists('photo', $_FILES)) {
        array_push($errors, 'Not got the photo.');
    } elseif ($_FILES['photo']['error'] > 0) {
        array_push($errors, 'There was an error uploading the photo.');
    } elseif (!is_uploaded_file($_FILES['photo']['tmp_name'])) {
        array_push($errors, 'Did not get an uploaded file.');
    } else {
        $tmp_name = $_FILES['photo']['tmp_name'];
        $image = imagick_readimage($tmp_name);
        if (!$image) {
            array_push($errors, 'Failed to read image from uploaded file');
        }
        $imageS = imagick_clonehandle($image);
        if (!imagick_scale($image, 118, 118, false)) {
            array_push($errors, 'Scaling large failed');
        }
        if (!imagick_scale($imageS, 59, 59, false)) {
            array_push($errors, 'Scaling small failed');
        }
        if (!imagick_writeimage($image, "{$dir}/mpsL/{$pid}.jpeg")) {
            array_push($errors, "Saving to {$dir}/mpsL/{$pid}.jpeg failed");
        }
        if (!imagick_writeimage($imageS, "{$dir}/mps/{$pid}.jpeg")) {
            array_push($errors, "Saving to {$dir}/mps/{$pid}.jpeg failed");
        }
        if (!$errors) {
            print "<pre>";
            chdir("{$dir}/mpsL");
            passthru("cvs -Q add -kb {$pid}.jpeg 2>&1");
            chdir("../mps");
            passthru("cvs -Q add -kb {$pid}.jpeg 2>&1");
            chdir("../");
            passthru('cvs -Q commit -m "Photo update from admin web photo upload interface." mpsL mps 2>&1');
            print "</pre>";
        }
    }
    if ($errors) {
        return display_form($errors);
    }
    return "<p><em>Photo uploaded and resized for pid {$pid}</em> &mdash; check how it looks <a href=\"/mp?p={$pid}\">on their page</a></p>" . display_form();
}
function _image_creer_vignette($valeurs, $maxWidth, $maxHeight, $process = 'AUTO', $force = false, $test_cache_only = false)
{
    // ordre de preference des formats graphiques pour creer les vignettes
    // le premier format disponible, selon la methode demandee, est utilise
    $image = $valeurs['fichier'];
    $format = $valeurs['format_source'];
    $destdir = dirname($valeurs['fichier_dest']);
    $destfile = basename($valeurs['fichier_dest'], "." . $valeurs["format_dest"]);
    $format_sortie = $valeurs['format_dest'];
    // liste des formats qu'on sait lire
    $img = isset($GLOBALS['meta']['formats_graphiques']) ? strpos($GLOBALS['meta']['formats_graphiques'], $format) !== false : false;
    // si le doc n'est pas une image, refuser
    if (!$force and !$img) {
        return;
    }
    $destination = "{$destdir}/{$destfile}";
    // chercher un cache
    $vignette = '';
    if ($test_cache_only and !$vignette) {
        return;
    }
    // utiliser le cache ?
    if (!$test_cache_only) {
        if ($force or !$vignette or @filemtime($vignette) < @filemtime($image)) {
            $creation = true;
            // calculer la taille
            if (($srcWidth = $valeurs['largeur']) && ($srcHeight = $valeurs['hauteur'])) {
                if (!($destWidth = $valeurs['largeur_dest']) || !($destHeight = $valeurs['hauteur_dest'])) {
                    list($destWidth, $destHeight) = _image_ratio($valeurs['largeur'], $valeurs['hauteur'], $maxWidth, $maxHeight);
                }
            } elseif ($process == 'convert' or $process == 'imagick') {
                $destWidth = $maxWidth;
                $destHeight = $maxHeight;
            } else {
                spip_log("echec {$process} sur {$image}");
                return;
            }
            // Si l'image est de la taille demandee (ou plus petite), simplement
            // la retourner
            if ($srcWidth and $srcWidth <= $maxWidth and $srcHeight <= $maxHeight) {
                $vignette = $destination . '.' . $format;
                @copy($image, $vignette);
            } else {
                if ($process == 'convert') {
                    define('_CONVERT_COMMAND', 'convert');
                    define('_RESIZE_COMMAND', _CONVERT_COMMAND . ' -quality ' . _IMG_CONVERT_QUALITE . ' -resize %xx%y! %src %dest');
                    $vignette = $destination . "." . $format_sortie;
                    $commande = str_replace(array('%x', '%y', '%src', '%dest'), array($destWidth, $destHeight, escapeshellcmd($image), escapeshellcmd($vignette)), _RESIZE_COMMAND);
                    spip_log($commande);
                    exec($commande);
                    if (!@file_exists($vignette)) {
                        spip_log("echec convert sur {$vignette}");
                        return;
                        // echec commande
                    }
                } else {
                    // imagick (php4-imagemagick)
                    if ($process == 'imagick') {
                        $vignette = "{$destination}." . $format_sortie;
                        $handle = imagick_readimage($image);
                        imagick_resize($handle, $destWidth, $destHeight, IMAGICK_FILTER_LANCZOS, _IMG_IMAGICK_QUALITE / 100);
                        imagick_write($handle, $vignette);
                        if (!@file_exists($vignette)) {
                            spip_log("echec imagick sur {$vignette}");
                            return;
                        }
                    } else {
                        // netpbm
                        if ($process == "netpbm") {
                            define('_PNMSCALE_COMMAND', 'pnmscale');
                            // chemin a changer dans mes_options
                            if (_PNMSCALE_COMMAND == '') {
                                return;
                            }
                            $vignette = $destination . "." . $format_sortie;
                            $pnmtojpeg_command = str_replace("pnmscale", "pnmtojpeg", _PNMSCALE_COMMAND);
                            if ($format == "jpg") {
                                $jpegtopnm_command = str_replace("pnmscale", "jpegtopnm", _PNMSCALE_COMMAND);
                                exec("{$jpegtopnm_command} {$image} | " . _PNMSCALE_COMMAND . " -width {$destWidth} | {$pnmtojpeg_command} > {$vignette}");
                                if (!($s = @filesize($vignette))) {
                                    spip_unlink($vignette);
                                }
                                if (!@file_exists($vignette)) {
                                    spip_log("echec netpbm-jpg sur {$vignette}");
                                    return;
                                }
                            } else {
                                if ($format == "gif") {
                                    $giftopnm_command = str_replace("pnmscale", "giftopnm", _PNMSCALE_COMMAND);
                                    exec("{$giftopnm_command} {$image} | " . _PNMSCALE_COMMAND . " -width {$destWidth} | {$pnmtojpeg_command} > {$vignette}");
                                    if (!($s = @filesize($vignette))) {
                                        spip_unlink($vignette);
                                    }
                                    if (!@file_exists($vignette)) {
                                        spip_log("echec netpbm-gif sur {$vignette}");
                                        return;
                                    }
                                } else {
                                    if ($format == "png") {
                                        $pngtopnm_command = str_replace("pnmscale", "pngtopnm", _PNMSCALE_COMMAND);
                                        exec("{$pngtopnm_command} {$image} | " . _PNMSCALE_COMMAND . " -width {$destWidth} | {$pnmtojpeg_command} > {$vignette}");
                                        if (!($s = @filesize($vignette))) {
                                            spip_unlink($vignette);
                                        }
                                        if (!@file_exists($vignette)) {
                                            spip_log("echec netpbm-png sur {$vignette}");
                                            return;
                                        }
                                    }
                                }
                            }
                        } else {
                            if ($process == 'gd1' or $process == 'gd2') {
                                if (_IMG_GD_MAX_PIXELS && $srcWidth * $srcHeight > _IMG_GD_MAX_PIXELS) {
                                    spip_log("vignette gd1/gd2 impossible : " . $srcWidth * $srcHeight . "pixels");
                                    return;
                                }
                                $destFormat = $format_sortie;
                                if (!$destFormat) {
                                    spip_log("pas de format pour {$image}");
                                    return;
                                }
                                $fonction_imagecreatefrom = $valeurs['fonction_imagecreatefrom'];
                                if (!function_exists($fonction_imagecreatefrom)) {
                                    return '';
                                }
                                $srcImage = @$fonction_imagecreatefrom($image);
                                if (!$srcImage) {
                                    spip_log("echec gd1/gd2");
                                    return;
                                }
                                // Initialisation de l'image destination
                                if ($process == 'gd2' and $destFormat != "gif") {
                                    $destImage = ImageCreateTrueColor($destWidth, $destHeight);
                                }
                                if (!$destImage) {
                                    $destImage = ImageCreate($destWidth, $destHeight);
                                }
                                // Recopie de l'image d'origine avec adaptation de la taille
                                $ok = false;
                                if ($process == 'gd2' and function_exists('ImageCopyResampled')) {
                                    if ($format == "gif") {
                                        // Si un GIF est transparent,
                                        // fabriquer un PNG transparent
                                        $transp = imagecolortransparent($srcImage);
                                        if ($transp > 0) {
                                            $destFormat = "png";
                                        }
                                    }
                                    if ($destFormat == "png") {
                                        // Conserver la transparence
                                        if (function_exists("imageAntiAlias")) {
                                            imageAntiAlias($destImage, true);
                                        }
                                        @imagealphablending($destImage, false);
                                        @imagesavealpha($destImage, true);
                                    }
                                    $ok = @ImageCopyResampled($destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight);
                                }
                                if (!$ok) {
                                    $ok = ImageCopyResized($destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight);
                                }
                                // Sauvegarde de l'image destination
                                $valeurs['fichier_dest'] = $vignette = "{$destination}.{$destFormat}";
                                $valeurs['format_dest'] = $format = $destFormat;
                                _image_gd_output($destImage, $valeurs);
                                if ($srcImage) {
                                    ImageDestroy($srcImage);
                                }
                                ImageDestroy($destImage);
                            }
                        }
                    }
                }
            }
        }
    }
    $size = @getimagesize($vignette);
    // Gaffe: en safe mode, pas d'acces a la vignette,
    // donc risque de balancer "width='0'", ce qui masque l'image sous MSIE
    if ($size[0] < 1) {
        $size[0] = $destWidth;
    }
    if ($size[1] < 1) {
        $size[1] = $destHeight;
    }
    $retour['width'] = $largeur = $size[0];
    $retour['height'] = $hauteur = $size[1];
    $retour['fichier'] = $vignette;
    $retour['format'] = $format;
    $retour['date'] = @filemtime($vignette);
    // renvoyer l'image
    return $retour;
}
function image_imagick()
{
    $tous = func_get_args();
    $img = $tous[0];
    $fonc = $tous[1];
    $tous[0] = "";
    $tous_var = join($tous, "-");
    $fonction = array('image_imagick', func_get_args());
    $image = _image_valeurs_trans($img, "{$tous_var}", "png", $fonction);
    if (!$image) {
        return "";
    }
    $im = $image["fichier"];
    $dest = $image["fichier_dest"];
    $creer = $image["creer"];
    if ($creer) {
        if (function_exists($fonc)) {
            $handle = imagick_readimage($im);
            $arr[0] = $handle;
            for ($i = 2; $i < count($tous); $i++) {
                $arr[] = $tous[$i];
            }
            call_user_func_array($fonc, $arr);
            // Creer image dans fichier temporaire, puis renommer vers "bon" fichier
            // de facon a eviter time_out pendant creation de l'image definitive
            $tmp = preg_replace(",[.]png\$,i", "-tmp.png", $dest);
            imagick_writeimage($handle, $tmp);
            rename($tmp, $dest);
            ecrire_fichier($dest . ".src", serialize($image));
        }
    }
    list($src_y, $src_x) = taille_image($dest);
    return _image_ecrire_tag($image, array('src' => $dest, 'width' => $src_x, 'height' => $src_y));
}
function bilder($width,$height,$dest) {
	//Wenn auf dem Server die php_imagick nicht installiert werden kann:
        //$rc=@exec("/usr/bin/convert -resize ".$width."x".$height." tmp/tmp.file_org tmp/tmp.file_$dest",$aus,$rc2);
        //if ($rc2>0) { echo "[Bildwandeln: $image.$dest]<br>";  return false; };

	if (!function_exists("imagick_readimage")) { echo "Imagick-Extention nicht installiert"; return false; };
	$handle=imagick_readimage("./tmp/tmp.file_org");
	if (!$handle) {
		$reason      = imagick_failedreason( $handle ) ;
		print "Lesen: $reason<BR>\n" ; flush();
		return false;
	}
	if (!imagick_resize( $handle, $width, $height, IMAGICK_FILTER_UNKNOWN, 0)) {
		$reason      = imagick_failedreason( $handle ) ;
		print "Resize: $reason<BR>\n" ;	flush();
		return false;
	}
	if (!imagick_writeimage( $handle,"./tmp/tmp.file_$dest")) {
		$reason      = imagick_failedreason( $handle ) ;
		print "Schreiben: $reason<BR>\n" ; 	flush();
		return false;
	}
	return true;
}
Example #10
0
 function _createBitmap($src)
 {
     // depends on imagick!
     if (!extension_loaded('imagick')) {
         dl('imagick.so');
     }
     // we litter files a bit here.. - we should do a clean up really..
     $srcTmp = ini_get('session.save_path') . '/' . uniqid('xsw_') . '_' . basename($src);
     $data = file_get_contents($src);
     $fh = fopen($srcTmp, 'w');
     fwrite($fh, $data);
     fclose($fh);
     $handle = imagick_readimage($srcTmp);
     $ret = ini_get('session.save_path') . '/' . uniqid('xsw_') . '_' . basename($src) . '.bmp';
     imagick_writeimage($handle, $ret);
     unlink($srcTmp);
     return $ret;
 }
Example #11
0
 public function landscape()
 {
     if (!HAS_IMAGICK) {
         throw new Exception('Landscape graphs need IMagick installed');
     }
     $filename = $this->makeFileName(true);
     $source = imagick_readimage($filename);
     $rotate = imagick_rotate($source, 270);
     imagick_writeimage($source, $filename);
 }
Example #12
0
/**
 * Given a path under dataroot, an ID and a size, return the path to a file
 * matching all criteria.
 *
 * If the file with the ID exists but not of the correct size, this function
 * will make a copy that is resized to the correct size.
 *
 * @param string $path The base path in dataroot where the image is stored. For 
 *                     example, 'artefact/file/profileicons/' for profile 
 *                     icons
 * @param int $id      The ID of the image to return. Is typically the ID of an 
 *                     artefact
 * @param mixed $size  The size the image should be.
 *
 *                      As a two element hash with 'w' and 'h' keys:
 *                     - If 'w' and 'h' are not empty, the image will be 
 *                       exactly that size
 *                     - If just 'w' is not empty, the image will be that wide, 
 *                       and the height will be set to make the image scale 
 *                       correctly
 *                     - If just 'h' is not empty, the image will be that high, 
 *                       and the width will be set to make the image scale 
 *                       correctly
 *                     - If neither are set or the parameter is not set, the 
 *                       image will not be resized
 *
 *                     As a number, the path returned will have the largest side being 
 *                     the length specified.
 * @return string The path on disk where the appropriate file resides, or false 
 *                if an appropriate file could not be located or generated
 */
function get_dataroot_image_path($path, $id, $size = null)
{
    $dataroot = get_config('dataroot');
    $imagepath = $dataroot . $path;
    if (substr($imagepath, -1) == '/') {
        $imagepath = substr($imagepath, 0, -1);
    }
    if (!is_dir($imagepath) || !is_readable($imagepath)) {
        return false;
    }
    // Work out the location of the original image
    $originalimage = $imagepath . '/originals/' . $id % 256 . "/{$id}";
    // If the original has been deleted, then don't show any image, even a cached one.
    // delete_image only deletes the original, not any cached ones, so we have
    // to make sure the original is still around
    if (!is_readable($originalimage)) {
        return false;
    }
    if (!$size) {
        // No size has been asked for. Return the original
        return $originalimage;
    } else {
        // Check if the image is available in the size requested
        $sizestr = serialize($size);
        $md5 = md5("{$id}.{$sizestr}");
        $resizedimagedir = $imagepath . '/resized/';
        check_dir_exists($resizedimagedir);
        for ($i = 0; $i <= 2; $i++) {
            $resizedimagedir .= substr($md5, $i, 1) . '/';
            check_dir_exists($resizedimagedir);
        }
        $resizedimagefile = "{$resizedimagedir}{$md5}.{$id}";
        //.$sizestr";
        if (is_readable($resizedimagefile)) {
            return $resizedimagefile;
        }
        // Image is not available in this size. If there is a base image for
        // it, we can make one however.
        if (is_readable($originalimage)) {
            $imageinfo = getimagesize($originalimage);
            $originalmimetype = $imageinfo['mime'];
            switch ($originalmimetype) {
                case 'image/jpeg':
                case 'image/jpg':
                    $oldih = imagecreatefromjpeg($originalimage);
                    break;
                case 'image/png':
                    $oldih = imagecreatefrompng($originalimage);
                    break;
                case 'image/gif':
                    $oldih = imagecreatefromgif($originalimage);
                    break;
                case 'image/bmp':
                case 'image/x-bmp':
                case 'image/ms-bmp':
                case 'image/x-ms-bmp':
                    if (!extension_loaded('imagick')) {
                        log_info('Bitmap image detected for resizing, but imagick extension is not available');
                        return false;
                    }
                    $ih = imagick_readimage($originalimage);
                    if (!($newdimensions = image_get_new_dimensions(imagick_getwidth($ih), imagick_getheight($ih), $size))) {
                        return false;
                    }
                    imagick_resize($ih, $newdimensions['w'], $newdimensions['h'], IMAGICK_FILTER_LANCZOS, 1);
                    if (imagick_writeimage($ih, $resizedimagefile)) {
                        return $resizedimagefile;
                    }
                    return false;
                default:
                    return false;
            }
            if (!$oldih) {
                return false;
            }
            $oldx = imagesx($oldih);
            $oldy = imagesy($oldih);
            if (!($newdimensions = image_get_new_dimensions($oldx, $oldy, $size))) {
                return false;
            }
            $newih = imagecreatetruecolor($newdimensions['w'], $newdimensions['h']);
            if ($originalmimetype == 'image/png' || $originalmimetype == 'image/gif') {
                // Create a new destination image which is completely
                // transparent and turn off alpha blending for it, so that when
                // the PNG source file is copied, the alpha channel is retained.
                // Thanks to http://alexle.net/archives/131
                $background = imagecolorallocate($newih, 0, 0, 0);
                imagecolortransparent($newih, $background);
                imagealphablending($newih, false);
                imagecopyresampled($newih, $oldih, 0, 0, 0, 0, $newdimensions['w'], $newdimensions['h'], $oldx, $oldy);
                imagesavealpha($newih, true);
            } else {
                // imagecopyresized is faster, but results in noticeably worse image quality.
                // Given the images are resized only once each time they're
                // made, I suggest you just leave the good quality one in place
                imagecopyresampled($newih, $oldih, 0, 0, 0, 0, $newdimensions['w'], $newdimensions['h'], $oldx, $oldy);
                //imagecopyresized($newih, $oldih, 0, 0, 0, 0, $newdimensions['w'], $newdimensions['h'], $oldx, $oldy);
            }
            $result = imagepng($newih, $resizedimagefile);
            if ($result) {
                return $resizedimagefile;
            }
        }
        // end attempting to build a resized image
    }
    // Image not available in any size
    return false;
}
Example #13
0
function action_tourner_post($r)
{
	$arg = $r[1];
	$row = sql_fetsel("fichier", "spip_documents", "id_document=$arg");

	if (!$row) return;

	include_spip('inc/charsets');	# pour le nom de fichier
	include_spip('inc/documents');
	// Fichier destination : on essaie toujours de repartir de l'original
	$var_rot = $r[2];
	include_spip('inc/distant'); # pour copie_locale
	$src = _DIR_RACINE . copie_locale(get_spip_doc($row['fichier']));
	if (preg_match(',^(.*)-r(90|180|270)\.([^.]+)$,', $src, $match)) {
		$effacer = $src;
		$src = $match[1].'.'.$match[3];
		$var_rot += intval($match[2]);
	}
	$var_rot = ((360 + $var_rot) % 360); // 0, 90, 180 ou 270

	if ($var_rot > 0) {
		$dest = preg_replace(',\.[^.]+$,', '-r'.$var_rot.'$0', $src);
		spip_log("rotation $var_rot $src : $dest");

		$process = $GLOBALS['meta']['image_process'];

		// imagick (php4-imagemagick)
		if ($process == 'imagick') {
			$handle = imagick_readimage($src);
			imagick_rotate($handle, $var_rot);
			imagick_write($handle, $dest);
			if (!@file_exists($dest)) return;	// echec imagick
		}
		else if ($process == "gd2") { // theoriquement compatible gd1, mais trop forte degradation d'image
			gdRotate ($src, $dest, $var_rot);
		}
		else if ($process == "convert") {
			if (_CONVERT_COMMAND!='') {
				define ('_CONVERT_COMMAND', 'convert');
				define ('_ROTATE_COMMAND', _CONVERT_COMMAND.' -rotate %t %src %dest');
			} else
				define ('_ROTATE_COMMAND', '');
			if (_ROTATE_COMMAND!=='') {
				$commande = str_replace(
					array('%t', '%src', '%dest'),
					array(
						$var_rot,
						escapeshellcmd($src),
						escapeshellcmd($dest)
					),
					_ROTATE_COMMAND);
				spip_log($commande);
				exec($commande);
			} else
				$dest = $src;
		}
	}
	else
		$dest = $src;

	$size_image = @getimagesize($dest);
	$largeur = $size_image[0];
	$hauteur = $size_image[1];

	// succes !
	if ($largeur>0 AND $hauteur>0) {
		sql_updateq('spip_documents', array('fichier' => set_spip_doc($dest), 'largeur'=>$largeur, 'hauteur'=>$hauteur), "id_document=$arg");
		if ($effacer) {
			spip_log("j'efface $effacer");
			spip_unlink($effacer);
		}
		// pipeline pour les plugins
		pipeline('post_edition',
			array(
				'args' => array(
					'table' => 'spip_documents',
					'table_objet' => 'documents',
					'spip_table_objet' => 'spip_documents',
					'type' =>'document',
					'id_objet' => $arg,
					'champs' => array('rotation'=>$r[2],'orientation'=>$var_rot,'fichier'=>$row),
					'serveur' => $serveur,
					'action'=>'tourner',
				),
				'data' => array('fichier'=>$row)
			)
		);
	}

}
Example #14
0
function liberty_imagick0_rotate_image(&$pFileHash)
{
    $ret = FALSE;
    if (!empty($pFileHash['source_file']) && is_file($pFileHash['source_file'])) {
        $iImg = imagick_readimage($pFileHash['source_file']);
        if (!$iImg) {
            $pFileHash['error'] = $pFileHash['name'] . ' ' . tra("is not a known image file");
        } elseif (imagick_iserror($iImg)) {
            $pFileHash['error'] = imagick_failedreason($iImg) . imagick_faileddescription($iImg);
        } elseif (empty($pFileHash['degrees']) || !is_numeric($pFileHash['degrees'])) {
            $pFileHash['error'] = tra('Invalid rotation amount');
        } else {
            if (!imagick_rotate($iImg, $pFileHash['degrees'])) {
                $pFileHash['error'] .= imagick_failedreason($iImg) . imagick_faileddescription($iImg);
            }
            if (!imagick_writeimage($iImg, $pFileHash['source_file'])) {
                $pFileHash['error'] .= imagick_failedreason($iImg) . imagick_faileddescription($iImg);
            }
        }
    } else {
        $pFileHash['error'] = "No source file to resize";
    }
    return empty($pFileHash['error']);
}