Created
December 14, 2019 13:47
-
-
Save hiroshikuze/8972ee52ef58f8324af3cc5d0b7f36e8 to your computer and use it in GitHub Desktop.
サムネイルを作成するプログラム(2010/4/12現在)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* サムネイルを作成するプログラム | |
* image_resize.php | |
*/ | |
include("[[phpThumbnailerの保存先]]"); | |
$ir_temp = "[[サムネイル作業用保存先]]"; | |
$changedomain = "[[サムネイルが表示できない時のスペーサー保存先]]/spacer.jpg"; | |
$filename = $_GET["file"]; | |
$width = $_GET["width"]; | |
$height = $_GET["height"]; | |
$okdomain = array("image.movapic.com", "[[ホームページのドメイン]]"); | |
$checkdomain = FALSE; | |
for($i = 0; $i < count($okdomain); $i++) { | |
if (strpos($filename,$okdomain[$i]) > 0) { | |
$checkdomain = TRUE; | |
break; | |
} | |
} | |
if($checkdomain == FALSE | |
or strlen($filename) == 0 | |
or $width == 0 | |
or $height == 0 | |
) { $filename = $changedomain; } | |
$pathinfo = pathinfo($filename); | |
$extension = ".".$pathinfo['extension']; | |
$ir_temp = str_replace($extension, md5($filename).$extension, $ir_temp); | |
image_resize($filename, $ir_temp, $width, $height); | |
exit(); | |
/** | |
* サムネイル作成本体部分 | |
* | |
* @param string ファイル名 | |
* @param string テンポラリファイル | |
* @param integer 横幅 | |
* @param integer 縦幅 | |
* @return void なし | |
*/ | |
function image_resize($filename, $tempfile, $width, $height) { | |
copy($filename, $tempfile); | |
$HyakkeiImage = new Thumbnail($tempfile, $width, $height, 0); | |
$HyakkeiImage->show(); | |
unlink($tempfile); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment