Bildqualität einstellbar ??!!

HerrB
Beiträge: 6935
Registriert: Do 22. Mai 2003, 12:44
Wohnort: Berlin
Kontaktdaten:

Beitrag von HerrB » Do 27. Apr 2006, 13:18

Erste Fundstelle sieht dann so aus:

Code: Alles auswählen

$x = imagesx($imageHandle);
$y = imagesy($imageHandle);

if ($x <= $maxX && $y <= $maxY) { 
      return str_replace($cfgClient[$client]["path"]["frontend"], $cfgClient[$client]["path"]["htmlpath"], $img); 
   } else {
Und die Anleitung sagt, füge unter $y = imagesy($imageHandle); den Code ein, d.h.

Code: Alles auswählen

$x = imagesx($imageHandle);
$y = imagesy($imageHandle);

// Hier ist neu
if ($x <= $maxX && $y <= $maxY) { 
      return str_replace($cfgClient[$client]["path"]["frontend"], $cfgClient[$client]["path"]["htmlpath"], $img); 
   } else {
// bis hier

if ($x <= $maxX && $y <= $maxY) { 
      return str_replace($cfgClient[$client]["path"]["frontend"], $cfgClient[$client]["path"]["htmlpath"], $img); 
   } else {
Es gibt zwei Funktionen mit diesem Konstrukt, für die zweite Stelle kriegst Du es auch ohne weitere Hilfe hin, bin ich mir gaaaaanz sicher...
und an der Dritten Stelle?
Ergänze ich das auch so?

Code: Alles auswählen

Für die dritte Stelle suchst Du nach list($x, $y) = getimagesize($filename); ... 
Nein, ich wollte Dich nur verarschen ... :roll:

Jaaaaaaaaaaaaa!

Code: Alles auswählen

   list($x, $y) = getimagesize($filename);

// Hier ist neu
if ($x <= $maxX && $y <= $maxY) { 
      return str_replace($cfgClient[$client]["path"]["frontend"], $cfgClient[$client]["path"]["htmlpath"], $img); 
   } else {
// bis hier

   /* Calculate the aspect ratio */    
   $aspectXY = $x / $y; 
   $aspectYX = $y / $x; 
Wie gesagt, ist ein Hotfix, ästhetisch nicht schön und ungetestet, aber könnte gehen...
Weiß nicht so recht wo dann die funktion zu Ende ist bzw. die Klammer noch eingesetzt werden muss. Bei allen?
Du musst die Ersetzung in drei Funktionen machen - also nicht bei allen, sondern nur bei denen, in denen Du die Zeilen ergänzt hast. Eine Funktion ist zu Ende, wenn die letzte } der Funktion ganz links steht (und nicht mehr eingerückt ist).

Beispiel für die erste Funktion, so sieht das Ende aus (und der erste Kommentar der nachfolgenden Funktion):

Code: Alles auswählen

   return ($webFile); 
} 

/** 
 * capiImgScaleHQ: Scales (or crops) an image in high quality. 
Und vor dem } kommt eine weitere }, also:

Code: Alles auswählen

   return ($webFile);
}
} 

/** 
 * capiImgScaleHQ: Scales (or crops) an image in high quality.
So, jetzt wirst Du es aber hinkriegen. Und ja, wenn es zu Fehlermeldungen kommt, einfach Fragen, keine Panik (vorher funktionierende Version sichern).

Gruß
HerrB
Bitte keine unaufgeforderten PMs oder E-Mails -> use da Forum!

Newsletter: V4.4.x | V4.6.0-15 (Module, Backend) | V4.6.22+
Standardartikelliste: V4.4.x | V4.6.x
http://www.contenido.org/forum/search.php | http://faq.contenido.org | http://www.communido.net

HerrB
Beiträge: 6935
Registriert: Do 22. Mai 2003, 12:44
Wohnort: Berlin
Kontaktdaten:

Beitrag von HerrB » Do 27. Apr 2006, 13:22

Habe aus Versehen das "Ich versteh's nicht" von kenzo überschrieben. Anleitung siehe oben.

Gruß
HerrB
Bitte keine unaufgeforderten PMs oder E-Mails -> use da Forum!

Newsletter: V4.4.x | V4.6.0-15 (Module, Backend) | V4.6.22+
Standardartikelliste: V4.4.x | V4.6.x
http://www.contenido.org/forum/search.php | http://faq.contenido.org | http://www.communido.net

kenzo
Beiträge: 112
Registriert: Di 8. Jul 2003, 19:46
Kontaktdaten:

Keine Fehler im Script aber . . .

Beitrag von kenzo » Do 27. Apr 2006, 20:11

Hi Alter ;-)

habe alles so gemacht wie Du schreibst, habe keine Fehler im Script, aber
Die bilder werden immer noch reduziert.

Ich setze Das Modul Illustration zweimal ein.
und es kommt, ziemlich komisch, vor, das es manchmal normal angezeigt wird und dann wieder reduziert wird (also nicht in Originalgröße).

Dies betrifft ausschließlich jpg`s. Beim gif gibt es keine Probleme.
Noch eins ist unverständlich.
Ich habe jetz in der Dateiverwaltung massenweise Kopien von den reduzierten Bildern, als ob contenido die da ablegt.
Alle haben die größe_größe_Dateiname mit dem Suffix *.jpg.jpg

Hab die Befürchtung, hier wird es ein Speicherproblem beim Webspace geben wenn ich da nicht was anders mache.

Was meinst Du?

Halchteranerin
Beiträge: 5478
Registriert: Di 2. Mär 2004, 21:11
Wohnort: Halchter, wo sonst? ;-)
Kontaktdaten:

Beitrag von Halchteranerin » Do 27. Apr 2006, 20:32

hmm, um welches Modul geht's bei dir kenzo? Du schreibst ja etwas vom Illustrationsmodul, das scheint das mitgelieferte zu sein. Aber das mit der doppelten Dateiendung kenne ich nur von Andreas Kummers Modulen. Oder macht das Illustrationsmodul das auch?
Bitte keine unaufgeforderten Privatnachrichten mit Hilfegesuchen schicken. WENN ich helfen kann, dann mache ich das im Forum, da ich auch alle Postings lese. PN werden nicht beantwortet!

kenzo
Beiträge: 112
Registriert: Di 8. Jul 2003, 19:46
Kontaktdaten:

ja . . .

Beitrag von kenzo » Do 27. Apr 2006, 21:33

Hi Halchteranerin,

Ja, so ist es .
Das Standardmodul Illustration aus der 4.6.8
Gibt es eine Alternative?

Halchteranerin
Beiträge: 5478
Registriert: Di 2. Mär 2004, 21:11
Wohnort: Halchter, wo sonst? ;-)
Kontaktdaten:

Beitrag von Halchteranerin » Do 27. Apr 2006, 22:07

ob es Alternativen gibt, weiss ich nicht, weil ich es nicht wirklich kenne (ich kenn's nur vom Namen her, hab's aber nicht benutzt). Aber wie gesagt, ich wuerde auch erstmal klaeren, ob diese doppelte Endung von diesem oder doch von einem anderen Modul kommt ...
Bitte keine unaufgeforderten Privatnachrichten mit Hilfegesuchen schicken. WENN ich helfen kann, dann mache ich das im Forum, da ich auch alle Postings lese. PN werden nicht beantwortet!

HerrB
Beiträge: 6935
Registriert: Do 22. Mai 2003, 12:44
Wohnort: Berlin
Kontaktdaten:

Beitrag von HerrB » Do 27. Apr 2006, 22:42

Warum er es mal macht und mal nicht, bin ich gerade überfragt. Bitte poste mal die fertige Datei.

Zum Modul Illustration findet sich im Forum auch eine Überarbeitung, die im Modul abfragt, ob eine Größenänderung erforderlich ist. Link habe ich gerade nicht zur Hand.

Gruß
HerrB
Bitte keine unaufgeforderten PMs oder E-Mails -> use da Forum!

Newsletter: V4.4.x | V4.6.0-15 (Module, Backend) | V4.6.22+
Standardartikelliste: V4.4.x | V4.6.x
http://www.contenido.org/forum/search.php | http://faq.contenido.org | http://www.communido.net

kenzo
Beiträge: 112
Registriert: Di 8. Jul 2003, 19:46
Kontaktdaten:

Beitrag von kenzo » Fr 28. Apr 2006, 11:45

Das ist die modifizierte Datei:

Code: Alles auswählen

<?php

/*****************************************
* File      :   $RCSfile: functions.api.images.php,v $
* Project   :   Contenido
* Descr     :   Contenido Image API functions
*
* Author    :   $Author: timo.hummel $
*               
* Created   :   08.08.2003
* Modified  :   $Date: 2006/01/13 17:43:45 $
*
* © four for business AG, www.4fb.de
*
* $Id: functions.api.images.php,v 1.37 2006/01/13 17:43:45 timo.hummel Exp $
******************************************/

/* Info:
 * This file contains Contenido Image API functions.
 *
 * If you are planning to add a function, please make sure that:
 * 1.) The function is in the correct place
 * 2.) The function is documented
 * 3.) The function makes sense and is generically usable
 *
 */
 
 
/**
 * capiImgScaleGetMD5CacheFile: Returns the MD5 Filename used
 * for caching.
 *
 * @return string Path to the resulting image
 */
function capiImgScaleGetMD5CacheFile ($sImg, $iMaxX, $iMaxY, $bCrop, $bExpand)
{
	if (!file_exists($sImg))
	{
		return false;	
	}
	
	$iFilesize = filesize($sImg);
	
	if (function_exists("md5_file"))
	{
		$sMD5 = md5(implode("", array(
					$sImg,
					md5_file($sImg),
					$iFilesize,
					$iMaxX,
					$iMaxY,
					$bCrop,
					$bExpand)));
	} else {
		$sMD5 = md5(implode("", array(
					$sImg,
					$iFilesize,
					$iMaxX,
					$iMaxY,
					$bCrop,
					$bExpand)));		
	}
	
	return $sMD5;
}

/**
 * capiImgScaleLQ: Scales (or crops) an image.
 * If scaling, the aspect ratio is maintained.
 *
 * Returns the path to the scaled temporary image.
 *
 * Note that this function does some very poor caching;
 * it calculates an md5 hash out of the image plus the
 * maximum X and Y sizes, and uses that as the file name.
 * If the file is older than 10 minutes, regenerate it.
 *
 * @param $img string The path to the image (relative to the frontend)
 * @param $maxX int The maximum size in x-direction
 * @param $maxY int The maximum size in y-direction
 * @param $crop boolean If true, the image is cropped and not scaled.
 * @param $expand boolean If true, the image is expanded (e.g. really scaled).
 *                        If false, the image will only be made smaller. 
 * @param $cacheTime int The number of minutes to cache the image  
 *
 * @return string Path to the resulting image
 */
function capiImgScaleLQ ($img, $maxX, $maxY, $crop = false, $expand = false, $cacheTime = 10)
{
	global $cfgClient, $lang, $client;

	$filename = $img;
	$defaultCacheTime = $cacheTime;
	
	$filetype = substr($filename, strlen($filename) -4,4);
	$filesize = filesize($img);
	$md5 = capiImgScaleGetMD5CacheFile($img, $maxX, $maxY, $crop, $expand);
	
	/* Create the target file names for web and server */
	$cfileName = $md5.".jpg";
	$cacheFile = $cfgClient[$client]["path"]["frontend"]."cache/".$cfileName;
	$webFile = $cfgClient[$client]["path"]["htmlpath"]."cache/".$cfileName;
	
	/* Check if the file exists. If it does, check if the file is valid. */
	if (file_exists($cacheFile))
	{
		if (!function_exists("md5_file"))
		{
			if ((filemtime($cacheFile) + (60 * $defaultCacheTime)) < time())
			{
				/* Cache time expired, unlink the file */
				unlink($cacheFile);	
			} else {
				/* Return the web file name */
				return $webFile;
			}
		} else {
			return $webFile;	
		}
	}
	
	/* Get out which file we have */
	switch (strtolower($filetype))
	{
		case ".gif": $function = "imagecreatefromgif"; break;
		case ".png": $function = "imagecreatefrompng"; break;
		case ".jpg": $function = "imagecreatefromjpeg"; break;
		case "jpeg": $function = "imagecreatefromjpeg"; break;
		default: return false;
	}
	
	if (function_exists($function))
	{
		$imageHandle = @$function($filename);
	}
	
	/* If we can't open the image, return false */
	if (!$imageHandle)
	{
		return false;
	}


	$x = imagesx($imageHandle);
	$y = imagesy($imageHandle);
[b][color=red]// Hier ist neu 
if ($x <= $maxX && $y <= $maxY) { 
      return str_replace($cfgClient[$client]["path"]["frontend"], $cfgClient[$client]["path"]["htmlpath"], $img); 
   } else { 
// bis hier [/color][/b]


	
	/* Calculate the aspect ratio */	
	$aspectXY = $x / $y;
	$aspectYX = $y / $x;
	
	if (($maxX / $x) < ($maxY / $y))
	{
		$targetY = $y * ($maxX / $x);
		$targetX = round($maxX);
		
		// force wished height
		if ($targetY < $maxY)
		{
			$targetY = ceil($targetY);
		} else
		{
			$targetY = floor($targetY);
		}
		
	} else {
		$targetX = $x * ($maxY / $y);
		$targetY = round($maxY);
		
		// force wished width
		if ($targetX < $maxX)
		{
			$targetX = ceil($targetX);
		} else
		{
			$targetX = floor($targetX);
		}
	}

	if ($expand == false && (($targetX > $x) || ($targetY > $y)))
	{
		$targetX = $x;
		$targetY = $y;	
	}

	$targetX = ($targetX != 0) ? $targetX : 1;
   	$targetY = ($targetY != 0) ? $targetY : 1;
   	
	/* Create the target image with the target size, resize it afterwards. */
   if ($crop)
   {
      /* Create the target image with the max size, crop it afterwards. */
      $targetImage = imagecreate($maxX, $maxY);
      imagecopy($targetImage, $imageHandle, 0, 0, 0, 0, $maxX, $maxY);
   } else {
      /* Create the target image with the target size, resize it afterwards. */
      $targetImage = imagecreate($targetX, $targetY);
      imagecopyresized($targetImage, $imageHandle, 0, 0, 0, 0, $targetX, $targetY, $x, $y);
   }
	
	/* Output the file */
	imagejpeg($targetImage, $cacheFile);
	
	return ($webFile);
[b][color=red]}[/color][/b]
}
/**
 * capiImgScaleHQ: Scales (or crops) an image in high quality.
 * If scaling, the aspect ratio is maintained.
 *
 * Note: GDLib 2.x is required!
 *
 * Returns the path to the scaled temporary image.
 *
 * Note that this function does some very poor caching;
 * it calculates an md5 hash out of the image plus the
 * maximum X and Y sizes, and uses that as the file name.
 * If the file is older than the specified cache time, regenerate it.
 *
 * @param $img string The path to the image (relative to the frontend)
 * @param $maxX int The maximum size in x-direction
 * @param $maxY int The maximum size in y-direction
 * @param $crop boolean If true, the image is cropped and not scaled.
 * @param $cacheTime int The number of minutes to cache the image  
 *
 * @return string Path to the resulting image
 */
function capiImgScaleHQ ($img, $maxX, $maxY, $crop = false, $expand = false, $cacheTime = 10)
{
	global $cfgClient, $lang, $client;

	$filename = $img;
	$defaultCacheTime = $cacheTime;
	
	$filetype = substr($filename, strlen($filename) -4,4);
	$filesize = filesize($img);
	$md5 = capiImgScaleGetMD5CacheFile($img, $maxX, $maxY, $crop, $expand);
	
	/* Create the target file names for web and server */
	$cfileName = $md5.".jpg";
	$cacheFile = $cfgClient[$client]["path"]["frontend"]."cache/".$cfileName;
	$webFile = $cfgClient[$client]["path"]["htmlpath"]."cache/".$cfileName;
	
	/* Check if the file exists. If it does, check if the file is valid. */
	if (file_exists($cacheFile))
	{
		if (!function_exists("md5_file"))
		{
			if ((filemtime($cacheFile) + (60 * $defaultCacheTime)) < time())
			{
				/* Cache time expired, unlink the file */
				unlink($cacheFile);	
			} else {
				/* Return the web file name */
				return $webFile;
			}
		} else {
			return $webFile;	
		}
	}
	
	/* Get out which file we have */
	switch (strtolower($filetype))
	{
		case ".gif": $function = "imagecreatefromgif"; break;
		case ".png": $function = "imagecreatefrompng"; break;
		case ".jpg": $function = "imagecreatefromjpeg"; break;
		case "jpeg": $function = "imagecreatefromjpeg"; break;
		default: return false;
	}
	
	if (function_exists($function))
	{
		$imageHandle = @$function($filename); 
	}
	
	/* If we can't open the image, return false */
	if (!$imageHandle)
	{
		return false;
	}


	$x = imagesx($imageHandle);
	$y = imagesy($imageHandle);

[color=red][b]	// Hier ist neu 
if ($x <= $maxX && $y <= $maxY) { 
      return str_replace($cfgClient[$client]["path"]["frontend"], $cfgClient[$client]["path"]["htmlpath"], $img); 
   } else { 
// bis hier [/b][/color]

	/* Calculate the aspect ratio */	
	$aspectXY = $x / $y;
	$aspectYX = $y / $x;
	
	if (($maxX / $x) < ($maxY / $y))
	{
		$targetY = $y * ($maxX / $x);
		$targetX = round($maxX);
		
		// force wished height
		if ($targetY < $maxY)
		{
			$targetY = ceil($targetY);
		} else
		{
			$targetY = floor($targetY);
		}
		
	} else {
		$targetX = $x * ($maxY / $y);
		$targetY = round($maxY);
		
		// force wished width
		if ($targetX < $maxX)
		{
			$targetX = ceil($targetX);
		} else
		{
			$targetX = floor($targetX);
		}
	}
	
	if ($expand == false && (($targetX > $x) || ($targetY > $y)))
	{
		$targetX = $x;
		$targetY = $y;	
	}	

	$targetX = ($targetX != 0) ? $targetX : 1;
   	$targetY = ($targetY != 0) ? $targetY : 1;
   	
	/* Create the target image with the target size, resize it afterwards. */
if ($crop)
   {
      /* Create the target image with the max size, crop it afterwards. */
      $targetImage = imagecreatetruecolor($maxX, $maxY);
      imagecopy($targetImage, $imageHandle, 0, 0, 0, 0, $maxX, $maxY);
   } else {
      /* Create the target image with the target size, resize it afterwards. */
      $targetImage = imagecreatetruecolor($targetX, $targetY);
      imagecopyresampled($targetImage, $imageHandle, 0, 0, 0, 0, $targetX, $targetY, $x, $y);
   }
	
	/* Output the file */
	imagejpeg($targetImage, $cacheFile);
	
	return ($webFile);
[[color=red]b]}[/b][/color]
}
/**
 * capiImgScaleImageMagick: Scales (or crops) an image using ImageMagick.
 * If scaling, the aspect ratio is maintained.
 *
 * Note: ImageMagick is required!
 *
 * Returns the path to the scaled temporary image.
 *
 * Note that this function does some very poor caching;
 * it calculates an md5 hash out of the image plus the
 * maximum X and Y sizes, and uses that as the file name.
 * If the file is older than the specified cache time, regenerate it.
 *
 * @param $img string The path to the image (relative to the frontend)
 * @param $maxX int The maximum size in x-direction
 * @param $maxY int The maximum size in y-direction
 * @param $crop boolean If true, the image is cropped and not scaled.
 * @param $cacheTime int The number of minutes to cache the image  
 *
 * @return string Path to the resulting image
 */
function capiImgScaleImageMagick ($img, $maxX, $maxY, $crop = false, $expand = false, $cacheTime = 10)
{
	global $cfgClient, $lang, $client;

	$filename = $img;
	$defaultCacheTime = $cacheTime;
	
	$filetype = substr($filename, strlen($filename) -4,4);
	$filesize = filesize($img);
	$md5 = capiImgScaleGetMD5CacheFile($img, $maxX, $maxY, $crop, $expand);
	
	/* Create the target file names for web and server */
	$cfileName = $md5.".jpg";
	$cacheFile = $cfgClient[$client]["path"]["frontend"]."cache/".$cfileName;
	$webFile = $cfgClient[$client]["path"]["htmlpath"]."cache/".$cfileName;
	
	/* Check if the file exists. If it does, check if the file is valid. */
	if (file_exists($cacheFile))
	{
		if (!function_exists("md5_file"))
		{
			if ((filemtime($cacheFile) + (60 * $defaultCacheTime)) < time())
			{
				/* Cache time expired, unlink the file */
				unlink($cacheFile);	
			} else {
				/* Return the web file name */
				return $webFile;
			}
		} else {
			return $webFile;	
		}
	}

	list($x, $y) = getimagesize($filename);	
[color=red][b]// Hier ist neu 
if ($x <= $maxX && $y <= $maxY) { 
      return str_replace($cfgClient[$client]["path"]["frontend"], $cfgClient[$client]["path"]["htmlpath"], $img); 
   } else { 
// bis hier [/b][/color]

	/* Calculate the aspect ratio */	
	$aspectXY = $x / $y;
	$aspectYX = $y / $x;
	
	if (($maxX / $x) < ($maxY / $y))
	{
		$targetY = $y * ($maxX / $x);
		$targetX = round($maxX);
		
		// force wished height
		if ($targetY < $maxY)
		{
			$targetY = ceil($targetY);
		} else
		{
			$targetY = floor($targetY);
		}
		
	} else {
		$targetX = $x * ($maxY / $y);
		$targetY = round($maxY);
		
		// force wished width
		if ($targetX < $maxX)
		{
			$targetX = ceil($targetX);
		} else
		{
			$targetX = floor($targetX);
		}
	}
	
	if ($expand == false && (($targetX > $x) || ($targetY > $y)))
	{
		$targetX = $x;
		$targetY = $y;	
	}
	
	$targetX = ($targetX != 0) ? $targetX : 1;
   	$targetY = ($targetY != 0) ? $targetY : 1;	

	// if is animated gif resize first frame
	if ($filetype == ".gif")
    {
		if (isAnimGif($filename))
        {
			$filename .= "[0]";
        }
    }

	/* Try to execute convert */
	if ($crop)
	{
		exec ("convert -gravity center -quality 75 -crop {$maxX}x{$maxY}+1+1 \"$filename\" $cacheFile", $output, $retVal);
	} else {
		exec ("convert -quality 75 -geometry {$targetX}x{$targetY} \"$filename\" $cacheFile", $output, $retVal );
	}

	if (!file_exists($cacheFile))
	{
		return false;
	}
	
	return ($webFile);
[color=red][b]}[/b][/color]}
/**
 * check if gif is animated
 *
 * @param string file path
 *
 * @return boolean true (gif is animated)/ false (single frame gif)
 */
function isAnimGif($sFile)
{
	$output = array();

	exec('identify ' . $sFile, $output, $retval);
	
	if (count($output) == 1)
	{
		return false;
	}
	
	return true;	
}

/**
 * capiImgScale: Scales (or crops) an image.
 * If scaling, the aspect ratio is maintained.
 *
 * This function chooses the best method to scale, depending on
 * the system environment and/or the parameters.
 *
 * Returns the path to the scaled temporary image.
 *
 * Note that this function does some very poor caching;
 * it calculates an md5 hash out of the image plus the
 * maximum X and Y sizes, and uses that as the file name.
 * If the file is older than 10 minutes, regenerate it.
 *
 * @param $img string The path to the image (relative to the frontend)
 * @param $maxX int The maximum size in x-direction
 * @param $maxY int The maximum size in y-direction
 * @param $crop boolean If true, the image is cropped and not scaled.
 * @param $expand boolean If true, the image is expanded (e.g. really scaled).
 *                        If false, the image will only be made smaller. 
 * @param $cacheTime int The number of minutes to cache the image  
 * @param $wantHQ boolean If true, try to force high quality mode
 *
 * @return string Path to the resulting image
 */
function capiImgScale ($img, $maxX, $maxY, $crop = false, $expand = false, $cacheTime = 10, $wantHQ = false)
{
	global $client, $db, $cfg, $cfgClient;
	
	$deleteAfter = false;
	
	if (!file_exists($img))
	{
		/* Try with upload string */
		if (file_exists($cfgClient[$client]["upl"]["path"].$img) && !is_dir($cfgClient[$client]["upl"]["path"].$img))
		{
			$img = $cfgClient[$client]["upl"]["path"].$img;
		} else {
    		/* DBFS-Based file */
    		if (is_dbfs($img))
    		{
    			$dbfs = new DBFSCollection;
    			
    			$file = basename($img);
    			
    			$dbfs->writeToFile($img, $cfgClient[$client]["path"]["frontend"]."cache/".$file);
    			
    			$img = $cfgClient[$client]["path"]["frontend"]."cache/".$file;
    			$deleteAfter = true;
    		} else {
    			/* No, it's neither in the upload directory nor in the dbfs. return. */
    			return false;
    		}
		}
			
	}
	
	$filename = $img;
	$filetype = substr($filename, strlen($filename) -4,4);
	
	$mxdAvImgEditingPosibility= checkImageEditingPosibility();
	switch ($mxdAvImgEditingPosibility)
	{
		case '1': // gd1
			$method = 'gd1';
			if (!function_exists('imagecreatefromgif') && $filetype == '.gif') 
			{
				$method = 'failure';
			}
			break;
		case '2': //gd2
			$method = 'gd2';
			if ($filetype == '.gif')
			{
				$method = 'failure';
			}
			break;
		case 'im': //imagemagick
			$method = 'im';
			break;
		case '0':
			$method = 'failure';
			break;
		default:
			$method = 'failure';
			break;
	}
	
	switch ($method)
	{
		case 'gd1':
			$return = capiImgScaleLQ($img, $maxX, $maxY, $crop, $expand, $cacheTime);	
			break;
		
		case 'gd2':
			$return = capiImgScaleHQ($img, $maxX, $maxY, $crop, $expand, $cacheTime);
			break;
		
		case 'im':
			$return = capiImgScaleImageMagick($img, $maxX, $maxY, $crop, $expand, $cacheTime);
			break;
		
		case 'failure':
        	$return = str_replace($cfgClient[$client]["path"]["frontend"], $cfgClient[$client]["path"]["htmlpath"], $img);
			break;
	}
	
	if ($deleteAfter == true)
	{
		unlink($img);
	}
	
	return $return;
					
}

/**
* check possible image editing functionality
*
* return mixed information about installed image editing extensions/tools
*/
function checkImageEditingPosibility() {

	if (isImageMagickAvailable())
	{
		return 'im';
	} else
	{
		if (extension_loaded('gd'))
		{
			if (function_exists('gd_info'))
			{
				$arrGDInformations = gd_info();
			
				if (preg_match('#([0-9\.])+#', $arrGDInformations['GD Version'], $strGDVersion))
				{
					if ($strGDVersion[0] >= '2')
					{
						return '2';
					}
					return '1';
				}
				return '1';
			}
			return '1';
		}
		return '0';
	}
	return '1';
}

?>

Und das Modul:

Input:

Code: Alles auswählen

?><?php
/***********************************************
* CONTENIDO MODUL - INPUT
*
* Modulname   :     Illustration
* Author(s)   :     Andreas Lindner, 4fb
* Copyright   :     Contenido - four for business, Andreas Lindner
* Created     :     12.08.2005
************************************************/

#Selected img directory
$cms_dirname = "CMS_VALUE[1]";
#Selected img
$cms_filename = "CMS_VALUE[2]";

if ($cms_dirname == '' || $cms_dirname == '0') {
	$cms_dirname = 'bilder/';
}

#Get paths
$sql = "SELECT
	htmlpath, frontendpath
	FROM
	".$cfg["tab"]["clients"]." 
	WHERE
	idclient = ".$client." ";

$db->query($sql);

if ($db->next_record()) {
	$htmlpath = $db->f('htmlpath');
	$frontendpath = $db->f('frontendpath');
}

#Choose image folder
echo '<table cellpadding="0" cellspacing="0" border="0">
	<tr><td class="text_medium" style="padding:5px">'.mi18n("Das Bild soll folgende Größe haben: 170 x 80 px").'</td></tr>
	<tr><td class="text_medium" style="padding:5px">'.mi18n("Bildverzeichnis wählen").': </td></tr>
	<tr><td class="text_medium" style="padding:5px">';
echo '<select name="CMS_VAR[1]" style="width:200px">';

#Get upload directories
$sql = "SELECT DISTINCT
	dirname
	FROM
	".$cfg["tab"]["upl"]."
	WHERE
	idclient='$client' AND
	filetype IN ('jpeg','jpg','gif','png')
	ORDER BY
	dirname";

$db->query($sql);

$selected = false;
while ($db->next_record()) {
	$dirname = $db->f('dirname');
	if ($cms_dirname != $dirname) {
		echo '<option value="'.$dirname.'">&nbsp;'.$dirname.'</option>';
	} else {
		$selected = true;
		echo '<option value="'.$dirname.'" selected="selected">&nbsp;'.$dirname.'</option>';
	}
}

if (!$selected) {
	echo '<option value="0" selected="selected">'.i18n("Bitte wählen").'</option>';
} else {
	echo '<option value="0">'.i18n("Bitte wählen").'</option>';
}

#Choose image file
echo '</select>&nbsp;<input type="image" src="images/submit.gif">
	<tr><td class="text_medium" style="padding:5px">'.mi18n("Bild wählen").': </td></tr>
	<tr><td class="text_medium" style="padding:5px">';
echo '<select name="CMS_VAR[2]" style="width:200px">';
echo '<option value="0" selected="selected">'.i18n("Bitte wählen").'</option>';

if ($cms_dirname != '0') {
	#Get uploaded files
	$sql = "SELECT 
			filename
			FROM
			".$cfg["tab"]["upl"]."
			WHERE
			idclient = '$client' AND
			filetype IN ('jpeg','jpg','gif','png','swf') AND
			dirname = '$cms_dirname' 
			ORDER BY
			filename";

	$db->query($sql);

	while ($db->next_record()) {
		$img_name = $db->f('filename');
		if ($cms_filename != $img_name) {
			echo '<option value="'.$img_name.'">&nbsp;'.$img_name.'</option>';
		} else {
			echo '<option selected="selected" value="'.$img_name.'">&nbsp;'.$img_name.'</option>';
		}
	}
}

echo '</select>&nbsp;<input type="image" src="images/submit.gif">';

#Preview image
if ($cms_dirname != '0' AND $cms_filename != '0' AND strlen($cms_dirname) > 0 AND strlen($cms_filename) > 0) {
	$img_path = $htmlpath.$cfgClient[$client]['upload'].$cms_dirname.$cms_filename;
	$img_split = preg_split("/\./", $cms_filename);
	$count = count($img_split);
	$type = $img_split[$count -1];

	echo '<tr><td colspan="2" style="padding:5px">		
				<img src="'.$img_path.'">
			</td></tr> ';
}

echo '</td></tr>';
echo '</table>';
?><?php 
Output:

Code: Alles auswählen

<?php
/***********************************************
* CONTENIDO MODUL - OUTPUT
*
* Modulname   :     Illustration
* Author(s)   :     Andreas Lindner, 4fb
* Copyright   :     Contenido - four for business, Andreas Lindner
* Created     :     12.08.2005
************************************************/

#Selected img directory
$cms_dirname = "CMS_VALUE[1]";
#Selected img
$cms_filename = "CMS_VALUE[2]";

#Default settings
$img_width = 170;
$img_height = 80;
$defaultImage = 'bilder/illu.jpg';

$htmlpath = $cfgClient[$client]['path']['htmlpath'];
$frontendpath = $cfgClient[$client]['path']['frontend'];

$img_path = $htmlpath.$cfgClient[$client]['upload'].$defaultImage;
$img_path_fs = $frontendpath.$cfgClient[$client]['upload'].$defaultImage;

#Check configured images
if ($cms_dirname != '0' AND $cms_filename != '0' AND strlen($cms_dirname) > 0 AND strlen($cms_filename) > 0) {
	$img_path = $htmlpath.$cfgClient[$client]['upload'].$cms_dirname.$cms_filename;
	$img_path_fs = $frontendpath.$cfgClient[$client]['upload'].$cms_dirname.$cms_filename;

	$img_split = preg_split("/\./", $cms_filename);
	$count = count($img_split);
	$type = $img_split[$count -1];

	if (!file_exists($img_path_fs)) {
		$img_path = $htmlpath.$cfgClient[$client]['upload'].$defaultImage;
		$img_path_fs = $frontendpath.$cfgClient[$client]['upload'].$defaultImage;
	}
}

#Scale image
$image = capiImgScale($img_path_fs, $img_width, $img_height, false, false, 10, false);

#Get dimensions of scaled image
list ($width, $height, $type, $attr) = getimagesize($image);
#Output image tag
echo '<img src="'.$image.'" width="'.$width.'" height="'.$height.'" alt="'.mi18n("Illustration").'" title="'.mi18n("Illustration").'"/>';
?>
Ich lösche mal via FTP die Kopien, vielciht sind die ja von mir unbemerkt vorher schon angelegt und werden jetzt nach dem Mod nur vom CMS benutzt weil bis auf den Suffix der Name ja gleich ist.

Wieder mit Ergebnis

Vielen Dank schon mal im Voraus :)

Gesperrt