Yeah ppl have asked many times from me about shotcutter so here it is. It's shitty code, I know and I have made it long time ago so plz no whine or I will remove it.
http://happo.info/~iler/shotcutter.phps
You can ask questions from me about it and I can TRY to answer these questions. And for all the hax hax people those paths don't work on the server anymore, those are there only as an example
[PHP] Shotcutter v. 0.01
Moderator: Moderators
[PHP] Shotcutter v. 0.01
paino on voimaa, ylipaino on ylivoimaa BD http://www.clanunited.org
nice one,
but to make a long code short, here's a function that I made figuring out a shotcropper.
works with every resolution(if there's a widescreen resolution i doubt it will work correctly)
http://clan.tardation.org/cropper/ <-- test over there..
but to make a long code short, here's a function that I made figuring out a shotcropper.
works with every resolution(if there's a widescreen resolution i doubt it will work correctly)
http://clan.tardation.org/cropper/ <-- test over there..
Code: Select all
function crop($imgOrig)
{
$imgSource = ImageCreateFromjpeg($imgOrig);
$x = imagesx($imgSource);
$y = imagesy($imgSource);
$mikux = 152;
$mikuy = 116;
$kokox = 335;
$kokoy = 165;
if($x == 640 || $y == 480) { $kx = $mikux; $ky = $mikuy; $check = "1";
} elseif($x > 640) { $kx = (($x - 640)/2) + $mikux; $ky = (($y - 480)/2) + $mikuy; $check = "1"; }
else { $kx = ((640 - $x)/2) - $mikux; $ky = ((480 - $y)/2) - $mikuy; $check = "1"; }
if($check) {
$imgCrop = imagecreatetruecolor($kokox,$kokoy);
ImageCopyResized($imgCrop, $imgSource, 0, 0, $kx, $ky, $kokox,$kokoy, $kokox, $kokoy);
unset($check);
return $imgCrop;
}
}
Oon tomaattikastikkeen läski mansikkarahka
-
- tripped on its own grenade
- Posts: 331
- Joined: Tue Aug 26, 2003 11:20 am
- Location: de
- Contact:
$ ./cutimage.sh inputfile outputfile
Sets the canvas of any picture from 800x600 to 640x480. (not scaling).
Requires imagemagick installed. Oh, and it's for linux/unix systems.
For scoreshots you'll probably change X2 to 320 and Y2 to 240.
Code: Select all
#/bin/sh
X1=800
Y1=600
X2=640
Y2=480
convert -shave `expr \( $X1 - $X2 \) / 2`x`expr \( $Y1 - $Y2 \) / 2` $1 $2
Requires imagemagick installed. Oh, and it's for linux/unix systems.
For scoreshots you'll probably change X2 to 320 and Y2 to 240.
Owner of http://aq2maps.quadaver.org
Not part of #aq2admins for a reason.
Not part of #aq2admins for a reason.
Code: Select all
function convert_image($img)
{
if (empty($img[name])) { die ("Image field is empty."); }
if (!ereg ('.jpg$', strtolower($img[name]))) { die ("$img[name] is not a jpg file."); }
$image_src = imagecreatefromjpeg("$img[tmp_name]");
$old_size_x = imagesx($image_src);
$old_size_y = imagesy($image_src);
$extrasize = 3; //size of extra area around the score
$new_size_x = 320 + (2 * $extrasize);
$new_size_y = 152 + (2 * $extrasize);
//Calculate the coord where to cut
$cut_x = ($old_size_x / 2) - 160 - $extrasize;
$cut_y = ($old_size_y / 2) - 120 - $extrasize;
//Create new image
$image_dst = imagecreatetruecolor($new_size_x, $new_size_y);
imagecopy($image_dst, $image_src, 0, 0, $cut_x, $cut_y, $new_size_x, $new_size_y);
return $image_dst;
}