<?php
/* PROJECT INFO --------------------------------------------------------------------------------------------------------
Version: 1.5.2
Changelog: http://adaptive-images.com/changelog.txt
Homepage: http://adaptive-images.com
GitHub: https://github.com/MattWilcox/Adaptive-Images
Twitter: @responsiveimg
LEGAL:
Adaptive Images by Matt Wilcox is licensed under a Creative Commons Attribution 3.0 Unported License.
/* CONFIG ----------------------------------------------------------------------------------------------------------- */
$resolutions = array(1600, 1400, 1200, 768, 480); // the resolution break-points to use (screen widths, in pixels)
$cache_path = "ai-cache"; // where to store the generated re-sized images. Specify from your document root!
$jpg_quality = 75; // the quality of any generated JPGs on a scale of 0 to 100
$sharpen = TRUE; // Shrinking images can blur details, perform a sharpen on re-scaled images?
$watch_cache = TRUE; // check that the adapted image isn't stale (ensures updated source images are re-cached)
$browser_cache = 60*60*24*7; // How long the BROWSER cache should last (seconds, minutes, hours, days. 7days by default)
/* END CONFIG ----------------------------------------------------------------------------------------------------------
------------------------ Don't edit anything after this line unless you know what you're doing -------------------------
--------------------------------------------------------------------------------------------------------------------- */
/* get all of the required data from the HTTP request */
$document_root = $_SERVER['DOCUMENT_ROOT'];
$requested_uri = parse_url(urldecode($_SERVER['REQUEST_URI']), PHP_URL_PATH);
$requested_file = basename($requested_uri);
$source_file = $document_root.$requested_uri;
$resolution = FALSE;
/* Mobile detection
NOTE: only used in the event a cookie isn't available. */
function is_mobile() {
$userAgent = strtolower($_SERVER['HTTP_USER_AGENT']);
return strpos($userAgent, 'mobile');
}
/* Does the UA string indicate this is a mobile? */
if(!is_mobile()){
$is_mobile = FALSE;
} else {
$is_mobile = TRUE;
}
// does the $cache_path directory exist already?
if (!is_dir("$document_root/$cache_path")) { // no
if (!mkdir("$document_root/$cache_path", 0755, true)) { // so make it
if (!is_dir("$document_root/$cache_path")) { // check again to protect against race conditions
// uh-oh, failed to make that directory
sendErrorImage("Failed to create cache directory at: $document_root/$cache_path");
}
}
}
/* helper function: Send headers and returns an image. */
function sendImage($filename, $browser_cache) {
$extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
if (in_array($extension, array('png', 'gif', 'jpeg'))) {
header("Content-Type: image/".$extension);
} else {
header("Content-Type: image/jpeg");
}
header("Cache-Control: private, max-age=".$browser_cache);
header('Expires: '.gmdate('D, d M Y H:i:s', time()+$browser_cache).' GMT');
header('Content-Length: '.filesize($filename));
readfile($filename);
exit();
}
/* helper function: Create and send an image with an error message. */
function sendErrorImage($message) {
/* get all of the required data from the HTTP request */
$document_root = $_SERVER['DOCUMENT_ROOT'];
$requested_uri = parse_url(urldecode($_SERVER['REQUEST_URI']), PHP_URL_PATH);
$requested_file = basename($requested_uri);
$source_file = $document_root.$requested_uri;
if(!is_mobile()){
$is_mobile = "FALSE";
} else {
$is_mobile = "TRUE";
}
$im = ImageCreateTrueColor(800, 300);
$text_color = ImageColorAllocate($im, 233, 14, 91);
$message_color = ImageColorAllocate($im, 91, 112, 233);
ImageString($im, 5, 5, 5, "Adaptive Images encountered a problem:", $text_color);
ImageString($im, 3, 5, 25, $message, $message_color);
ImageString($im, 5, 5, 85, "Potentially useful information:", $text_color);
ImageString($im, 3, 5, 105, "DOCUMENT ROOT IS: $document_root", $text_color);
ImageString($im, 3, 5, 125, "REQUESTED URI WAS: $requested_uri", $text_color);
ImageString($im, 3, 5, 145, "REQUESTED FILE WAS: $requested_file", $text_color);
ImageString($im, 3, 5, 165, "SOURCE FILE IS: $source_file", $text_color);
ImageString($im, 3, 5, 185, "DEVICE IS MOBILE? $is_mobile", $text_color);
header("Cache-Control: no-store");
header('Expires: '.gmdate('D, d M Y H:i:s', time()-1000).' GMT');
header('Content-Type: image/jpeg');
ImageJpeg($im);
ImageDestroy($im);
exit();
}
/* sharpen images function */
function findSharp($intOrig, $intFinal) {
$intFinal = $intFinal * (750.0 / $intOrig);
$intA = 52;
$intB = -0.27810650887573124;
$intC = .00047337278106508946;
$intRes = $intA + $intB * $intFinal + $intC * $intFinal * $intFinal;
return max(round($intRes), 0);
}
/* refreshes the cached image if it's outdated */
function refreshCache($source_file, $cache_file, $resolution) {
if (file_exists($cache_file)) {
// not modified
if (filemtime($cache_file) >= filemtime($source_file)) {
return $cache_file;
}
// modified, clear it
unlink($cache_file);
}
return generateImage($source_file, $cache_file, $resolution);
}
/* generates the given cache file for the given source file with the given resolution */
function generateImage($source_file, $cache_file, $resolution) {
global $sharpen, $jpg_quality;
$extension = strtolower(pathinfo($source_file, PATHINFO_EXTENSION));
// Check the image dimensions
$dimensions = GetImageSize($source_file);
$width = $dimensions[0];
$height = $dimensions[1];
// Do we need to downscale the image?
if ($width <= $resolution) { // no, because the width of the source image is already less than the client width
return $source_file;
}
// We need to resize the source image to the width of the resolution breakpoint we're working with
$ratio = $height/$width;
$new_width = $resolution;
$new_height = ceil($new_width * $ratio);
$dst = ImageCreateTrueColor($new_width, $new_height); // re-sized image
switch ($extension) {
case 'png':
$src = @ImageCreateFromPng($source_file); // original image
break;
case 'gif':
$src = @ImageCreateFromGif($source_file); // original image
break;
default:
$src = @ImageCreateFromJpeg($source_file); // original image
ImageInterlace($dst, true); // Enable interlancing (progressive JPG, smaller size file)
break;
}
if($extension=='png'){
imagealphablending($dst, false);
imagesavealpha($dst,true);
$transparent = imagecolorallocatealpha($dst, 255, 255, 255, 127);
imagefilledrectangle($dst, 0, 0, $new_width, $new_height, $transparent);
}
ImageCopyResampled($dst, $src, 0, 0, 0, 0, $new_width, $new_height, $width, $height); // do the resize in memory
ImageDestroy($src);
// sharpen the image?
// NOTE: requires PHP compiled with the bundled version of GD (see http://php.net/manual/en/function.imageconvolution.php)
if($sharpen == TRUE && function_exists('imageconvolution')) {
$intSharpness = findSharp($width, $new_width);
$arrMatrix = array(
array(-1, -2, -1),
array(-2, $intSharpness + 12, -2),
array(-1, -2, -1)
);
imageconvolution($dst, $arrMatrix, $intSharpness, 0);
}
$cache_dir = dirname($cache_file);
// does the directory exist already?
if (!is_dir($cache_dir)) {
if (!mkdir($cache_dir, 0755, true)) {
// check again if it really doesn't exist to protect against race conditions
if (!is_dir($cache_dir)) {
// uh-oh, failed to make that directory
ImageDestroy($dst);
sendErrorImage("Failed to create cache directory: $cache_dir");
}
}
}
if (!is_writable($cache_dir)) {
sendErrorImage("The cache directory is not writable: $cache_dir");
}
// s
没有合适的资源?快使用搜索试试~ 我知道了~
黑色个性的图片个人博客模板_黑色 个性 html5 个人 博客.rar
共126个文件
html:47个
woff:14个
ttf:14个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 175 浏览量
2023-04-27
14:54:28
上传
评论
收藏 5.68MB RAR 举报
温馨提示
黑色个性的图片个人博客模板_黑色 个性 html5 个人 博客
资源推荐
资源详情
资源评论
收起资源包目录
黑色个性的图片个人博客模板_黑色 个性 html5 个人 博客.rar (126个子文件)
main.css 15KB
font-awesome.css 14KB
normalize.css 9KB
font-face.css 7KB
typography.css 5KB
juicy-orange.css 5KB
hot-pink.css 4KB
hot-pink.css 2KB
ocean-blue.css 2KB
juicy-orange.css 2KB
ocean-blue.css 2KB
fontawesome-webfont.eot 38KB
Banda_regular-webfont.eot 37KB
sofia-regular-webfont.eot 31KB
OpenSans-LightItalic-webfont.eot 24KB
OpenSans-SemiboldItalic-webfont.eot 23KB
OpenSans-Italic-webfont.eot 23KB
Matchbook-webfont.eot 23KB
OpenSans-BoldItalic-webfont.eot 23KB
OpenSans-ExtraBoldItalic-webfont.eot 23KB
OpenSans-Bold-webfont.eot 21KB
OpenSans-ExtraBold-webfont.eot 21KB
OpenSans-Semibold-webfont.eot 21KB
OpenSans-Light-webfont.eot 20KB
OpenSans-Regular-webfont.eot 20KB
index.html 9KB
index.html 9KB
index.html 9KB
index.html 9KB
index.html 9KB
index.html 8KB
index.html 8KB
index.html 8KB
index.html 8KB
index.html 8KB
index.html 8KB
post.html 8KB
post.html 8KB
post.html 8KB
post.html 8KB
post.html 8KB
post.html 8KB
post.html 8KB
post.html 8KB
post.html 8KB
post.html 7KB
post.html 7KB
gallery-hex.html 6KB
gallery-hex.html 6KB
gallery-hex.html 6KB
gallery-hex.html 6KB
gallery-hex.html 6KB
gallery-hex.html 6KB
gallery.html 5KB
gallery.html 5KB
gallery.html 5KB
gallery.html 5KB
gallery.html 5KB
categories.html 5KB
404.html 5KB
gallery.html 4KB
single-image.html 4KB
single-image.html 4KB
single-image.html 4KB
single-image.html 4KB
single-image.html 4KB
single-image.html 4KB
single-image.html 4KB
single-image.html 4KB
single-image.html 4KB
single-image.html 4KB
single-image.html 4KB
image.jpg 3.59MB
02.jpg 482KB
01.jpg 334KB
03.jpg 224KB
placeholder.jpg 27KB
jquery-1.8.0.min.js 90KB
plugins.js 12KB
main.js 2KB
Banda_regular.otf 65KB
adaptive-images.php 12KB
brillant-dark.png 3KB
brillant.png 85B
fontawesome-webfont.svg 127KB
sofia-regular-webfont.svg 112KB
Banda_regular-webfont.svg 94KB
Matchbook-webfont.svg 33KB
OpenSans-Italic-webfont.svg 27KB
OpenSans-SemiboldItalic-webfont.svg 27KB
OpenSans-LightItalic-webfont.svg 27KB
OpenSans-ExtraBoldItalic-webfont.svg 26KB
OpenSans-BoldItalic-webfont.svg 26KB
OpenSans-ExtraBold-webfont.svg 25KB
OpenSans-Regular-webfont.svg 25KB
OpenSans-Semibold-webfont.svg 25KB
OpenSans-Bold-webfont.svg 25KB
OpenSans-Light-webfont.svg 24KB
Banda_regular-webfont.ttf 101KB
fontawesome-webfont.ttf 67KB
共 126 条
- 1
- 2
资源评论
紫微前端
- 粉丝: 4311
- 资源: 869
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功