image.php 0000604 00000007451 15245571253 0006353 0 ustar 00 = 0)
{
$X=0;
while ($X < $BMP['width'])
{
if ($BMP['bits_per_pixel'] == 24)
{
$COLOR = unpack("V",substr($IMG,$P,3).$VIDE);
}
elseif ($BMP['bits_per_pixel'] == 16)
{
$COLOR = unpack("v",substr($IMG,$P,2));
$blue = ($COLOR[1] & 0x001f) << 3;
$green = ($COLOR[1] & 0x07e0) >> 3;
$red = ($COLOR[1] & 0xf800) >> 8;
$COLOR[1] = $red * 65536 + $green * 256 + $blue;
}
elseif ($BMP['bits_per_pixel'] == 8)
{
$COLOR = unpack("n",$VIDE.substr($IMG,$P,1));
$COLOR[1] = $PALETTE[$COLOR[1]+1];
}
elseif ($BMP['bits_per_pixel'] == 4)
{
$COLOR = unpack("n",$VIDE.substr($IMG,floor($P),1));
if (($P*2)%2 == 0) $COLOR[1] = ($COLOR[1] >> 4) ; else $COLOR[1] = ($COLOR[1] & 0x0F);
$COLOR[1] = $PALETTE[$COLOR[1]+1];
}
elseif ($BMP['bits_per_pixel'] == 1)
{
$COLOR = unpack("n",$VIDE.substr($IMG,floor($P),1));
if (($P*8)%8 == 0) $COLOR[1] = $COLOR[1] >>7;
elseif (($P*8)%8 == 1) $COLOR[1] = ($COLOR[1] & 0x40)>>6;
elseif (($P*8)%8 == 2) $COLOR[1] = ($COLOR[1] & 0x20)>>5;
elseif (($P*8)%8 == 3) $COLOR[1] = ($COLOR[1] & 0x10)>>4;
elseif (($P*8)%8 == 4) $COLOR[1] = ($COLOR[1] & 0x8)>>3;
elseif (($P*8)%8 == 5) $COLOR[1] = ($COLOR[1] & 0x4)>>2;
elseif (($P*8)%8 == 6) $COLOR[1] = ($COLOR[1] & 0x2)>>1;
elseif (($P*8)%8 == 7) $COLOR[1] = ($COLOR[1] & 0x1);
$COLOR[1] = $PALETTE[$COLOR[1]+1];
}
else
return FALSE;
imagesetpixel($res,$X,$Y,$COLOR[1]);
$X++;
$P += $BMP['bytes_per_pixel'];
}
$Y--;
$P+=$BMP['decal'];
}
// Close file
fclose($f1);
return $res;
}
}
index.html 0000604 00000000037 15245571253 0006546 0 ustar 00
get.php 0000604 00000034330 15245571253 0006044 0 ustar 00
' . JText::_('ICLIB_INVALID_PICTURE_LINK') . '';
$Wrong_img_format = '
' . JText::_('ICLIB_NOT_AUTHORIZED_IMAGE_TYPE') . '
' . JText::_('ICLIB_NOT_AUTHORIZED_IMAGE_TYPE_INFO') . '';
$fopen_bmp_error = '
' . JText::_('ICLIB_PHP_ERROR_FOPEN_COPY_BMP') . '
' . JText::_('ICLIB_PHP_ERROR_FOPEN_COPY_BMP_INFO') . '';
$error_icthumb = '
' . JText::_('ICLIB_ERROR_ICTHUMB') . '
' . JText::_('ICLIB_ERROR_ICTHUMB_INFO') . '';
// Mime-Type pre-settings
$errorMimeTypeMsg = '
' . JText::_('ICLIB_ERROR_MIME_TYPE') . '
' . JText::_('ICLIB_ERROR_MIME_TYPE_NO_THUMBNAIL');
// Folder for copy of distant images, and jpg created from bmp
$copyPath = $thumbsPath . '/copy';
$cropped = $crop ? 'c' : '';
// Thumb Destination
if ($name)
{
$thumb_name = '';
}
elseif ($prefix)
{
$thumb_name = $prefix.'_w'.$width.'h'.$height.'q'.$quality.$cropped.'_';
}
else
{
$thumb_name = 'w'.$width.'h'.$height.'q'.$quality.$cropped.'_';
}
$thumb_destination = $subFolder . '/' . $thumb_name;
// Get Image File Infos
// $url = $image;
// $decomposition = explode( '/' , $url );
// in each parent
// $i = 0;
// while ( isset($decomposition[$i]) )
// $i++;
// $i--;
// $imgname = $decomposition[$i];
// $fichier = explode( '.', $decomposition[$i] );
// $imgtitle = $fichier[0];
// $imgextension = strtolower($fichier[1]); // fixed 3.1.10
$image_info = pathinfo($image);
$imgtitle = $image_info['filename'];
$imgextension = strtolower($image_info['extension']); // To be checked if error with uppercase extension type
// Clean file name
jimport( 'joomla.filter.output' );
$cleanFileName = JFilterOutput::stringURLSafe($imgtitle) . '.' . $imgextension;
$cleanTitle = JFilterOutput::stringURLSafe($imgtitle);
// Image pre-settings
$imageValue = $image;
$Image_Link = $image;
// url to thumbnails already created
$Thumb_Link = $thumbsPath . '/' . $thumb_destination . $cleanFileName;
$Thumb_aftercopy_Link = $thumbsPath . '/' . $thumb_destination . $cleanTitle . '.jpg';
// url to copy original jpg created
$MAX_aftercopy_Link = $copyPath . '/' . $cleanTitle . '.jpg';
$file_copy = JPATH_ROOT . '/' . $MAX_aftercopy_Link;
// Fix for previous version, if original image is too small (ic_large image only, used in event details view)
$original_too_small = false;
if ($prefix == 'ic_large')
{
$file_to_check = filter_var($image, FILTER_VALIDATE_URL) ? $file_copy : $file_local;
list($w, $h) = getimagesize($file_to_check);
if ($w < $width or $h < $height)
{
$max_image_size = filter_var($image, FILTER_VALIDATE_URL) ? $MAX_aftercopy_Link : $image;
$original_too_small = true;
}
}
// Check if thumbnails already created
if (file_exists(JPATH_ROOT . '/' . $Thumb_Link)
|| $original_too_small)
{
$Thumb_Link = $original_too_small ? $max_image_size : $Thumb_Link;
$Display_Thumb = true;
}
elseif (file_exists(JPATH_ROOT . '/' . $Thumb_aftercopy_Link)
|| $original_too_small)
{
$Thumb_Link = $original_too_small ? $max_image_size : $Thumb_aftercopy_Link;
$Display_Thumb = true;
}
// if thumbnails not already created, create thumbnails
else
{
$memory_limit = ini_get('memory_limit');
if (preg_match('/^(\d+)(.)$/', $memory_limit, $matches))
{
if ($matches[2] == 'M')
{
$memory_limit = $matches[1] * 1024 * 1024; // nnnM -> nnn MB
}
elseif ($matches[2] == 'K')
{
$memory_limit = $matches[1] * 1024; // nnnK -> nnn KB
}
}
list($w, $h) = getimagesize($linkToImage);
$rgba_factor = 4;
$security_factor = 1.8;
if (function_exists('memory_get_usage')
&& ( (($w * $h * $rgba_factor * $security_factor) + memory_get_usage()) > $memory_limit )
)
{
if ( $app->isAdmin() )
{
$alert_message = JText::sprintf('ICLIB_ERROR_ALERT_IMAGE_TOO_LARGE', $image);
// Get the message queue
$messages = $app->getMessageQueue();
$display_alert_message = false;
// If we have messages
if (is_array($messages) && count($messages))
{
// Check each message for the one we want
foreach ($messages as $key => $value)
{
if ($value['message'] == $alert_message)
{
$display_alert_message = true;
}
}
}
if (!$display_alert_message)
{
$app->enqueueMessage($alert_message, 'Warning');
}
return JText::_('ICLIB_ERROR_IMAGE_TOO_LARGE');
}
else
{
return false;
}
}
if (file_exists($linkToImage))
{
// Test Mime-Type
$fileinfos = getimagesize($linkToImage);
$mimeType = $fileinfos['mime'];
$extensionType = 'image/' . $imgextension;
// SETTINGS ICTHUMB
$errorMimeTypeInfo = '
' . JText::sprintf('ICLIB_ERROR_MIME_TYPE_INFO', $imgextension, $mimeType);
// Error message if Mime-Type is not the same as extension
if (($imgextension == 'jpeg') OR ($imgextension == 'jpg'))
{
if (($mimeType != 'image/jpeg') AND ($mimeType != 'image/jpg'))
{
$MimeTypeOK = false;
$MimeTypeERROR = true;
}
}
elseif ($imgextension == 'bmp')
{
if (($mimeType != 'image/bmp') AND ($mimeType != 'image/x-ms-bmp'))
{
$MimeTypeOK = false;
$MimeTypeERROR = true;
}
}
elseif ($mimeType != $extensionType)
{
$MimeTypeOK = false;
$MimeTypeERROR = true;
}
}
// If Error mime-type, no thumbnail creation
if ($MimeTypeOK)
{
// Call function and create image thumbnail for events list in admin
// If Image JPG, JPEG, PNG or GIF
if (($imgextension == "jpg") OR ($imgextension == "jpeg") OR ($imgextension == "png") OR ($imgextension == "gif"))
{
$Thumb_Link = $Thumb_Link;
if (!file_exists(JPATH_ROOT . '/' . $Thumb_Link))
{
if (filter_var($imageValue, FILTER_VALIDATE_URL))
{
if ((iCUrl::url_exists($imageValue)) AND ($fopen))
{
$testFile = JPATH_ROOT . '/' . $copyPath . '/' . $cleanFileName;
if (!file_exists($testFile))
{
//Get the file
$content = file_get_contents($imageValue);
//Store in the filesystem.
$fp = fopen(JPATH_ROOT . '/' . $copyPath . '/' . $cleanFileName, "w");
fwrite($fp, $content);
fclose($fp);
}
$linkToImage = JPATH_ROOT . '/' . $copyPath . '/' . $cleanFileName;
$imageValue = $copyPath . '/' . $cleanFileName;
}
else
{
$linkToImage = $imageValue;
}
}
else
{
$linkToImage = JPATH_ROOT . '/' . $imageValue;
}
if ((iCUrl::url_exists($linkToImage)) OR (file_exists($linkToImage)))
{
iCThumbCreate::createThumb($linkToImage, JPATH_ROOT . '/' . $Thumb_Link, $width, $height, $quality, $crop, $prefix, $checksize);
}
else
{
$Invalid_Link = true;
}
}
}
// If Image BMP
elseif ($imgextension == "bmp")
{
$Image_Link = $copyPath . '/' . $cleanTitle . '.jpg';
$Thumb_Link = $Thumb_aftercopy_Link;
if (!file_exists(JPATH_ROOT . '/' . $Thumb_Link))
{
if (filter_var($imageValue, FILTER_VALIDATE_URL))
{
if ((iCUrl::url_exists($imageValue)) AND ($fopen))
{
$testFile = JPATH_ROOT . '/' . $copyPath . '/' . $cleanTitle . '.jpg';
if (!file_exists($testFile))
{
// Get the file
$content = file_get_contents($imageValue);
// Store in the filesystem.
$fp = fopen(JPATH_ROOT . '/' . $copyPath . '/' . $cleanFileName, "w");
fwrite($fp, $content);
fclose($fp);
$imageNewValue = JPATH_ROOT . '/' . $copyPath . '/' . $cleanFileName;
imagejpeg(iCThumbImage::createFromBMP($imageNewValue), JPATH_ROOT . '/' . $copyPath . '/' . $cleanTitle . '.jpg', 100);
unlink($imageNewValue);
}
}
else
{
$linkToImage = $imageValue;
}
}
else
{
imagejpeg(iCThumbImage::createFromBMP(JPATH_ROOT . '/' . $imageValue), JPATH_ROOT . '/' . $copyPath . '/' . $cleanTitle . '.jpg', 100);
}
$imageValue = $copyPath . '/' . $cleanTitle . '.jpg';
$linkToImage = JPATH_ROOT . '/' . $imageValue;
if (!$fopen)
{
$fopen_bmp_error_msg = true;
}
elseif ((iCUrl::url_exists($linkToImage)) OR (file_exists($linkToImage)))
{
iCThumbCreate::createThumb($linkToImage, JPATH_ROOT . '/' . $Thumb_Link, $width, $height, $quality, $crop, $prefix, $checksize);
}
else
{
$Invalid_Link = true;
}
}
}
// If Not authorized Image Format
else
{
if ((iCUrl::url_exists($linkToImage)) OR (file_exists($linkToImage)))
{
$Invalid_Img_Format = true;
}
else
{
$Invalid_Link = true;
}
}
if (!$Invalid_Link)
{
$Display_Thumb = true;
}
}
// If error Mime-Type
else
{
if (($imgextension == "jpg")
OR ($imgextension == "jpeg")
OR ($imgextension == "png")
OR ($imgextension == "gif")
OR ($imgextension == "bmp"))
{
$MimeTypeERROR = true;
}
else
{
$Invalid_Img_Format = true;
$MimeTypeERROR = false;
}
}
}
if ($type == 'imgTag'
|| $type == 'imgTagLinkModal')
{
// Display Thumbnail Image tag
$thumbnailImgTag = '';
if ($Invalid_Img_Format)
{
$thumbnailImgTag.= $app->isAdmin() ? $Wrong_img_format : '';
}
if ($Invalid_Link)
{
$thumbnailImgTag.= $app->isAdmin() ? $Invalid_LinkMsg : '';
}
if ($MimeTypeERROR)
{
$thumbnailImgTag.= $app->isAdmin() ? $errorMimeTypeMsg : '';
$thumbnailImgTag.= $app->isAdmin() ? $errorMimeTypeInfo : '';
}
if ($fopen_bmp_error_msg)
{
$thumbnailImgTag.= $app->isAdmin() ? $fopen_bmp_error : '';
}
if ($Display_Thumb)
{
if ($imgextension == "bmp")
{
if ($type == 'imgTagLinkModal')
{
$thumbnailImgTag.= '';
}
$thumbnailImgTag.= '
';
if ($type == 'imgTagLinkModal')
{
$thumbnailImgTag.= '';
}
}
else
{
if ($type == 'imgTagLinkModal')
{
if (filter_var($Image_Link, FILTER_VALIDATE_URL))
{
$thumbnailImgTag.= '';
}
else
{
$thumbnailImgTag.= '';
}
}
$thumbnailImgTag.= '
';
if ($type == 'imgTagLinkModal')
{
$thumbnailImgTag.= '';
}
}
}
if ((!file_exists(JPATH_ROOT . '/' . $Thumb_Link)) && ($image) && (!$fopen))
{
$thumbnailImgTag.= $app->isAdmin() ? $error_icthumb : '';
}
return $thumbnailImgTag;
}
else
{
// Display Thumbnail Image tag
$thumb_img = '';
// Set Thumbnail
$default_thumbnail = 'media/com_icagenda/images/nophoto.jpg';
if ( $Invalid_Img_Format
|| $Invalid_Link
|| $MimeTypeERROR
|| $fopen_bmp_error_msg
|| ((!file_exists(JPATH_ROOT . '/' . $Thumb_Link)) && ($image)) )
{
$thumb_img = $default_thumbnail;
}
elseif ($Display_Thumb)
{
$thumb_img = $Thumb_Link;
}
return $thumb_img;
}
}
/**
* Return the thumbnail from an image, embed inside html tags
*
* @since 1.0.0
*/
static public function thumbnailImgTag($image, $thumbsPath, $subFolder,
$width, $height, $quality, $crop = null, $prefix = null)
{
$thumbnailImgTag = iCThumbGet::thumbnail($image, $thumbsPath, $subFolder, $width, $height, $quality, $crop, $prefix, 'imgTag');
return $thumbnailImgTag;
}
/**
* Return the thumbnail from an image, embed inside html tags
* Link on thumbnail opens original image in modal
*
* @since 1.0.0
*/
static public function thumbnailImgTagLinkModal($image, $thumbsPath, $subFolder,
$width, $height, $quality, $crop = null, $prefix = null)
{
$thumbnailImgTag = iCThumbGet::thumbnail($image, $thumbsPath, $subFolder, $width, $height, $quality, $crop, $prefix, 'imgTagLinkModal');
return $thumbnailImgTag;
}
}
create.php 0000604 00000006060 15245571253 0006527 0 ustar 00 get('thumb_large');
$width = is_numeric($thumbOptions[0]) ? $thumbOptions[0] : '900';
$height = is_numeric($thumbOptions[1]) ? $thumbOptions[1] : '600';
$quality = is_numeric($thumbOptions[2]) ? $thumbOptions[2] : '100';
$crop = !empty($thumbOptions[3]) ? true : false;
// Generate large thumb if not exist
$sizeLarge = iCThumbGet::thumbnail($image, $thumbsPath, 'themes', $width, $height, $quality, $crop, 'ic_large', $type, $checksize);
return $sizeLarge;
}
/**
* Return the MEDIUM thumbnail from an image
* Generated by iCagenda with Global Options settings
*
* @since 3.4.0
*/
static public function sizeMedium($image, $type = null, $checksize = null)
{
$thumbsPath = self::iCagendaImagesPath();
// Options Medium Size
$thumbOptions = JComponentHelper::getParams('com_icagenda')->get('thumb_medium');
$width = is_numeric($thumbOptions[0]) ? $thumbOptions[0] : '300';
$height = is_numeric($thumbOptions[1]) ? $thumbOptions[1] : '300';
$quality = is_numeric($thumbOptions[2]) ? $thumbOptions[2] : '100';
$crop = !empty($thumbOptions[3]) ? true : false;
// Generate medium thumb if not exist
$sizeMedium = iCThumbGet::thumbnail($image, $thumbsPath, 'themes', $width, $height, $quality, $crop, 'ic_medium', $type, $checksize);
return $sizeMedium;
}
/**
* Return the SMALL thumbnail from an image
* Generated by iCagenda with Global Options settings
*
* @since 3.4.0
*/
static public function sizeSmall($image, $type = null, $checksize = null)
{
$thumbsPath = self::iCagendaImagesPath();
// Options Small Size
$thumbOptions = JComponentHelper::getParams('com_icagenda')->get('thumb_small');
$width = is_numeric($thumbOptions[0]) ? $thumbOptions[0] : '100';
$height = is_numeric($thumbOptions[1]) ? $thumbOptions[1] : '100';
$quality = is_numeric($thumbOptions[2]) ? $thumbOptions[2] : '100';
$crop = !empty($thumbOptions[3]) ? true : false;
// Generate small thumb if not exist
$sizeSmall = iCThumbGet::thumbnail($image, $thumbsPath, 'themes', $width, $height, $quality, $crop, 'ic_small', $type, $checksize);
return $sizeSmall;
}
/**
* Return the SMALL thumbnail from an image
* Generated by iCagenda with Global Options settings
*
* @since 3.4.0
*/
static public function sizeXSmall($image, $type = null, $checksize = null)
{
$thumbsPath = self::iCagendaImagesPath();
// Options XSmall Size
$thumbOptions = JComponentHelper::getParams('com_icagenda')->get('thumb_xsmall');
$width = is_numeric($thumbOptions[0]) ? $thumbOptions[0] : '48';
$height = is_numeric($thumbOptions[1]) ? $thumbOptions[1] : '48';
$quality = is_numeric($thumbOptions[2]) ? $thumbOptions[2] : '80';
$crop = !empty($thumbOptions[3]) ? true : false;
// Generate xsmall thumb if not exist
$sizeXSmall = iCThumbGet::thumbnail($image, $thumbsPath, 'themes', $width, $height, $quality, $crop, 'ic_xsmall', $type, $checksize);
return $sizeXSmall;
}
/**
* Return the iCagenda images path
*
* @since 3.4.0
*/
static public function iCagendaImagesPath()
{
// Get media path
$params_media = JComponentHelper::getParams('com_media');
$image_path = $params_media->get('image_path', 'images');
// Paths to thumbs folder
$thumbsPath = $image_path . '/icagenda/thumbs';
return $thumbsPath;
}
}