Http://Dota.RajaGame.com/forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.


Http://Dota.RajaGame.com/forum
 
IndeksSimple Script Image Resizer & Copyright Stamp (PHP) I_icon_mini_portalLatest imagesPendaftaranLoginDota.RajaGame.com

 

 Simple Script Image Resizer & Copyright Stamp (PHP)

Go down 
PengirimMessage
DeviL_CRew
administration
administration
DeviL_CRew


Jumlah posting : 17
Age : 34
Location : Jakarta
Registration date : 25.11.08

Simple Script Image Resizer & Copyright Stamp (PHP) Empty
PostSubyek: Simple Script Image Resizer & Copyright Stamp (PHP)   Simple Script Image Resizer & Copyright Stamp (PHP) EmptySat Nov 29, 2008 12:31 pm

Script Image Resizing Process (saved as image_process.class.php)

by HR

<?php

class image_process {

var $copyright = "";
var $font_size;

function create_image($source_path,$out_path,$quality=75,$width=0,$height=0,$aspect_ratio=true,$thumbnail=false) {
// get the main image
$source_image = @imagecreatefromjpeg($source_path) ;
if (!$source_image) {
return;
}
$real_width = imagesx($source_image);
$real_height = imagesy($source_image);
$landscape = false;
if ($real_width > $real_height) {
$landscape = true;
}
// scaled size
if ($width == 0) { $scaled_width = $real_width; }
else { $scaled_width = $width; }
if ($height == 0) { $scaled_height = $real_height; }
else { $scaled_width = $width; }
if ($aspect_ratio) {
$scaled_ratio = $scaled_width / $scaled_height;
$image_ratio = $real_width / $real_height;
if ($scaled_ratio < $image_ratio) {
$scaled_height = (int)($scaled_width / $image_ratio);
} else {
$scaled_width = (int)($scaled_height * $image_ratio);
}
}
// create the canvas
if ($thumbnail) {
$image_ratio = $real_width / $real_height;
if ($landscape) {
$small_height = $height;
$small_width = (int)($small_height * $image_ratio);
}
else {
$small_width = $width;
$small_height = (int)($small_width / $image_ratio);
}
if ($landscape) {
$thumb_width = ($small_width-$width) / 2;
$thumb_height = 0;
}
else {
$thumb_height = ($small_height-$height) / 2;
$thumb_width = 0;
}
$dest_image = imagecreatetruecolor($width,$height) ;
$dest_thumb = imagecreatetruecolor($small_width,$small_height) ;
imagecopyresized($dest_thumb,$source_image,0,0,0,0,$small_width,$small_height,$real_width,$real_height) ;
imagecopy($dest_image,$dest_thumb,0,0,$thumb_width,$thumb_height,$width,$height) ;
}
else {
$dest_image = imagecreatetruecolor($scaled_width,$scaled_height) ;
imagecopyresized($dest_image,$source_image,0,0,0,0,$scaled_width,$scaled_height,$real_width,$real_height) or die("Problem In Resizing");
}
$real_width = imagesx($dest_image);
$real_height = imagesy($dest_image);
// copyright
if ($this->copyright != "") {
$char_width = imagefontwidth($this->font_size);
$char_height = imagefontheight($this->font_size);
$padding = 2;
$width = $padding * 2 + strlen($this->copyright) * $char_width;
$height = + $padding * 2 + $char_height;
$background = imagecolorallocate($dest_image, 200, 200, 200);
$text = imagecolorallocate($dest_image, 0, 0, 0);
imagefilledrectangle ($dest_image, 0, 0, $width, $height, $background);
imagestring($dest_image, $this->font_size, $padding, $padding, $this->copyright, $text);
}
imagejpeg($dest_image,$out_path,$quality) ;
imagedestroy($dest_image) ;
}
}

?>
Kembali Ke Atas Go down
Http://RajaGame-Community.forum-free.org
DeviL_CRew
administration
administration
DeviL_CRew


Jumlah posting : 17
Age : 34
Location : Jakarta
Registration date : 25.11.08

Simple Script Image Resizer & Copyright Stamp (PHP) Empty
PostSubyek: Simple Script Image Resizer & Copyright Stamp (PHP)   Simple Script Image Resizer & Copyright Stamp (PHP) EmptySat Nov 29, 2008 12:32 pm

Script Trigger nya (save as image_upload.class.php)

by HR

<?

require_once 'image_process.class.php';

class image_upload {
function generate_image($source_file,$out_file,$path,$copyright="") {
$process = new image_process();
$process->copyright = $copyright;
$srcname = $source_file;
// create the main
$destname = $path.$out_file;
$process->font_size = 1;
$process->create_image($srcname,$destname,75,300,300,true);
// create the thumbnail
$destname = $path.'thumbnail/'.$out_file;
$process->font_size = 0;
$process->create_image($srcname,$destname,75,150,150,true);
}

}
?>


Terakhir diubah oleh RajaGame tanggal Sat Nov 29, 2008 12:34 pm, total 1 kali diubah
Kembali Ke Atas Go down
Http://RajaGame-Community.forum-free.org
DeviL_CRew
administration
administration
DeviL_CRew


Jumlah posting : 17
Age : 34
Location : Jakarta
Registration date : 25.11.08

Simple Script Image Resizer & Copyright Stamp (PHP) Empty
PostSubyek: Simple Script Image Resizer & Copyright Stamp (PHP)   Simple Script Image Resizer & Copyright Stamp (PHP) EmptySat Nov 29, 2008 12:34 pm

Penggunaan pada web (setelah file di upload, ditempatkan pada bagian skrip pemroses)


require_once 'image_upload.class.php';

$upload = new image_upload();

if (is_file($_FILES['photo']['tmp_name'])) {

$newname = $_FILES['photo']['name']; // nama file yg tujuan
$destpath = 'images/'; // folder tujuan
$copyright = 'CODER Team'; // copyright text
$upload->generate_image($_FILES['photo']['tmp_name'],$newname,$destpath,$copyright);
}
Kembali Ke Atas Go down
Http://RajaGame-Community.forum-free.org
Sponsored content





Simple Script Image Resizer & Copyright Stamp (PHP) Empty
PostSubyek: Re: Simple Script Image Resizer & Copyright Stamp (PHP)   Simple Script Image Resizer & Copyright Stamp (PHP) Empty

Kembali Ke Atas Go down
 
Simple Script Image Resizer & Copyright Stamp (PHP)
Kembali Ke Atas 
Halaman 1 dari 1
 Similar topics
-
» Bunny Hop Script
» Script Mail Bomber

Permissions in this forum:Anda tidak dapat menjawab topik
Http://Dota.RajaGame.com/forum :: Informasi & Technology :: Programing-
Navigasi: