![]() $mime_type = trim(exec('file -bi '.escapeshellarg($filename))) $mime_type = trim(exec('file -mime '.escapeshellarg($filename))) $mime_type = trim(exec('file -b -mime-type '.escapeshellarg($filename))) $mime_type = mime_content_type($filename) $mime_type = finfo_file($finfo, $filename) Įlseif (function_exists('mime_content_type')) $const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME Try 4 different methods to determine the mime type $mime_type_list = array('image/gif', 'image/jpg', 'image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png') ![]() Public static function isRealImage($filename, $file_mime_type = null, $mime_type_list = null) * array $mime_type_list Allowed MIME types * string $file_mime_type File known mime type (generally from $_FILES) Return $dest_image->writeImage($dst_file) return (ImageManager::write($file_type, $dest_image, $dst_file)) *imagecopyresampled($dest_image, $src_image, (int)(($dst_width - $next_width) / 2), (int)(($dst_height - $next_height) / 2), 0, 0, $next_width, $next_height, $src_width, $src_height) */ Imagefilledrectangle ($dest_image, 0, 0, $dst_width, $dst_height, $white) Imagefilledrectangle($dest_image, 0, 0, $dst_width, $dst_height, $transparent) $transparent = imagecolorallocatealpha($dest_image, 255, 255, 255, 127) *if ($file_type = 'png' & $type = IMAGETYPE_PNG) If image is a PNG and the output is PNG, fill with transparency. $dest_image = imagecreatetruecolor($dst_width, $dst_height) $dest_image->writeImage('mythumb.gif') ![]() If (Configuration::get('PS_IMAGE_GENERATION_METHOD') = 2 || (!Configuration::get('PS_IMAGE_GENERATION_METHOD') & $width_diff resizeImage($dst_width, $dst_height, Imagick::FILTER_LANCZOS, 1) Public static function resize($src_file, $dst_file, $dst_width = null, $dst_height = null, $file_type = 'jpg', $force_type = false, &$error = 0) * integer $dst_height Desired height (optional) * integer $dst_width Desired width (optional) * string $src_file Image object from $_FILE $channel = isset($infos) ? ($infos / 8) : 1 If (function_exists('memory_get_usage') & (int)$memory_limit != -1) Public static function checkImageMemoryLimit($image) ![]() * Check if memory limit is too long or not If (Context::getContext()->controller->controller_type = 'admin') Relative link will always work, whatever the base uri set in the admin ImageManager::resize($image, _PS_TMP_IMG_DIR_.$cache_image, $ratio_x, $size, $image_type) If (!ImageManager::checkImageMemoryLimit($image)) Evaluate the memory required to resize the image: if it's too much, you can't resize it. If (file_exists(_PS_TMP_IMG_DIR_.$cache_image) & ($regenerate || !file_exists(_PS_TMP_IMG_DIR_.$cache_image)) Public static function thumbnail($image, $cache_image, $size, $image_type = 'jpg', $disable_cache = true, $regenerate = false) * bool $regenerate When turned on and the file already exist, the file will be regenerated * bool $disable_cache When turned on a timestamp will be added to the image URI to disable the HTTP cache * Generate a cached thumbnail for object lists (eg.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |