Außerdem wird auch ein Mid-Thumbnail (im Cacheordner) abgelegt, wenn es eigentlich gar nicht nötig wäre.

Dieses Snippet behebt diese Mankos.

- Code: Alles auswählen
#
#-----[ OPEN ]----------------------------------------------------------------
#
album_picm.php
#
#-----[ FIND ]----------------------------------------------------------------
#
* original work by smartor album_thumbnail.php
#
#-----[ BEFORE, ADD ]---------------------------------------------------------
#
* Modified by AmigaLink (http://www.amigalink.de/viewtopic.php?t=829)
*
#
#-----[ FIND ]----------------------------------------------------------------
#
// Check thumbnail cache. If cache is available we will SEND & EXIT
#
#-----[ FIND ]----------------------------------------------------------------
#
readfile(ALBUM_MED_CACHE_PATH . $pic_thumbnail);
#
#-----[ REPLACE WITH ]--------------------------------------------------------
#
if (defined('ALBUM_SP_CONFIG_TABLE'))
{
// --------------------------------------------------------
// Okay, now we insert the watermark for unregistered users
// --------------------------------------------------------
Watermark($pic_filename, $pic_filetype);
}
else
{
readfile(ALBUM_MED_CACHE_PATH . $pic_thumbnail);
}
#
#-----[ FIND ]----------------------------------------------------------------
#
$gd_errored = FALSE;
#
#-----[ AFTER, ADD ]----------------------------------------------------------
#
// No cache needet?
if( ($pic_width <= $album_sp_config['midthumb_width']) && ($pic_height <= $album_sp_config['midthumb_height']) )
{
switch ($pic_filetype)
{
case '.jpg':
header('Content-type: image/jpeg');
break;
case '.png':
header('Content-type: image/png');
break;
}
if (defined('ALBUM_SP_CONFIG_TABLE'))
{
// --------------------------------------------------------
// Okay, now we insert the watermark for unregistered users
// --------------------------------------------------------
Watermark($pic_filename, $pic_filetype, 1);
}
else
{
readfile(ALBUM_UPLOAD_PATH . $pic_filename);
}
exit;
}
// Re-generate
#
#-----[ FIND ]----------------------------------------------------------------
#
// ----------------------------
// After write to disk, donot forget to send to browser also
// ----------------------------
switch ($pic_filetype)
{
case '.jpg':
@imagejpeg($thumbnail, '', $album_config['thumbnail_quality']);
break;
case '.png':
@imagepng($thumbnail);
break;
}
exit;
#
#-----[ REPLACE WITH ]--------------------------------------------------------
#
// ----------------------------
// After write to disk, donot forget to send to browser also
// ----------------------------
if (defined('ALBUM_SP_CONFIG_TABLE'))
{
// --------------------------------------------------------
// Okay, now we insert the watermark for unregistered users
// --------------------------------------------------------
Watermark($pic_thumbnail, $pic_filetype);
}
else
{
switch ($pic_filetype)
{
case '.jpg':
@imagejpeg($thumbnail, '', $album_config['thumbnail_quality']);
break;
case '.png':
@imagepng($thumbnail);
break;
}
}
exit;
#
#-----[ FIND ]----------------------------------------------------------------
#
// +-------------------------------------------------------------+
// | Powered by Photo Album 2.x.x (c) 2002-2003 Smartor |
#
#-----[ BEFORE, ADD ]---------------------------------------------------------
#
function Watermark(&$pic_filename, &$pic_filetype, $type = 0)
{
global $album_root_path, $album_sp_config, $userdata;
$pic_path = ($type == 0) ? ALBUM_MED_CACHE_PATH : ALBUM_UPLOAD_PATH;
// ----------------------
// Let insert a watermark
// ----------------------
if( $pic_filetype != '.gif' && (!$userdata['session_logged_in'] || $userdata['user_level'] == USER) && $album_sp_config['use_watermark'] == 1)
{
$position = $album_sp_config['disp_watermark_at'];
$transition = 50;
$sourcefile = $pic_path . $pic_filename;
$insertfile = $album_root_path . 'mark.png';
mergePics($sourcefile, $insertfile, $position, $transition, $pic_filetype);
}
else if ($pic_filetype != '.gif' && $album_sp_config['wut_users'] == 1 && $album_sp_config['use_watermark'] == 1)
{
$position = $album_sp_config['disp_watermark_at'];
$transition = 70;
$sourcefile = $pic_path . $pic_filename;
$insertfile = $album_root_path . 'mark.png';
mergePics($sourcefile, $insertfile, $position, $transition, $pic_filetype);
}
else
{
readfile($pic_path . $pic_filename);
}
return;
}
function mergePics($sourcefile, $insertfile, $pos = 0, $transition = 50, $filetype)
{
$insertfile_id = imageCreateFromPNG($insertfile);
switch( $filetype )
{
case '.jpg':
$sourcefile_id = imageCreateFromJPEG($sourcefile);
break;
case '.png':
$sourcefile_id = imageCreateFromPNG($sourcefile);
break;
default:
break;
}
// Get the size of both pics
$sourcefile_width = imageSX($sourcefile_id);
$sourcefile_height = imageSY($sourcefile_id);
$insertfile_width = imageSX($insertfile_id);
$insertfile_height = imageSY($insertfile_id);
switch( $pos )
{
case 0: // middle
$dest_x = ( $sourcefile_width / 2 ) - ( $insertfile_width / 2 );
$dest_y = ( $sourcefile_height / 2 ) - ( $insertfile_height / 2 );
break;
case 1: // top left
$dest_x = 0;
$dest_y = 0;
break;
case 2: // top right
$dest_x = $sourcefile_width - $insertfile_width;
$dest_y = 0;
break;
case 3: // bottom right
$dest_x = $sourcefile_width - $insertfile_width;
$dest_y = $sourcefile_height - $insertfile_height;
break;
case 4: // bottom left
$dest_x = 0;
$dest_y = $sourcefile_height - $insertfile_height;
break;
case 5: // top middle
$dest_x = ( ( $sourcefile_width - $insertfile_width ) / 2 );
$dest_y = 0;
break;
case 6: // middle right
$dest_x = $sourcefile_width - $insertfile_width;
$dest_y = ( $sourcefile_height / 2 ) - ( $insertfile_height / 2 );
break;
case 7: // bottom middle
$dest_x = ( ( $sourcefile_width - $insertfile_width ) / 2 );
$dest_y = $sourcefile_height - $insertfile_height;
break;
case 8: // middle left
$dest_x = 0;
$dest_y = ( $sourcefile_height / 2 ) - ( $insertfile_height / 2 );
break;
default:
break;
}
// Merge the two pix
imageCopyMerge($sourcefile_id, $insertfile_id, $dest_x, $dest_y, 0, 0, $insertfile_width, $insertfile_height, $transition);
// Create the final image
switch( $filetype )
{
case '.jpg':
Imagejpeg($sourcefile_id, '', 75);
break;
case '.png':
Imagepng($sourcefile_id);
break;
default:
break;
}
ImageDestroy($sourcefile_id);
}
#
#-----[ FIND ]----------------------------------------------------------------
#
// | with Volodymyr (CLowN) Skoryk's Service Pack 1 © 2003-2004 |
// +-------------------------------------------------------------+
#
#-----[ AFTER, ADD ]----------------------------------------------------------
#
// | Modified 2007 by AmigaLink http://www.AmigaLink.de |
// +-------------------------------------------------------------+
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------------
#
# EoM
Entstanden ist dieses Snippet auf anfrage im http://www.amigalink.de/viewtopic.php?t=821 thread.
Eventuelle Fragen oder Probleme bitte dort melden!