[PHP] Shotcutter v. 0.01

Forum for anything hard- or software related.

Moderator: Moderators

Post Reply
iler
special poika polizai
Posts: 78
Joined: Mon Jul 28, 2003 9:19 am
Location: fi
Contact:

[PHP] Shotcutter v. 0.01

Post by iler »

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 :tsk:
paino on voimaa, ylipaino on ylivoimaa BD http://www.clanunited.org
MarlPoro
melted
Posts: 168
Joined: Sat Jan 10, 2004 11:11 am
Location: fi
Contact:

Post by MarlPoro »

It's a shitty and useless code! iler is the suckage!

No really, you R the hax \,,\
MarlPoro / Anxiety
Thanks for reading
Den
something dur dur
Posts: 2616
Joined: Fri Jul 25, 2003 8:56 am
Location: nl
Contact:

Post by Den »

poika power!
There's a chopper coming in 3 days and there's a katana on top of the cafe and that's all you need to know
Image
MikuzA
joined the game
Posts: 47
Joined: Mon Jul 28, 2003 11:49 am
Location: fi

Post by MikuzA »

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..

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
Haudrauf
tripped on its own grenade
Posts: 331
Joined: Tue Aug 26, 2003 11:20 am
Location: de
Contact:

Post by Haudrauf »

$ ./cutimage.sh inputfile outputfile

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
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. :)
ImageOwner of http://aq2maps.quadaver.org
Not part of #aq2admins for a reason.
Maniac-
joined the game
Posts: 29
Joined: Wed Aug 27, 2003 12:14 pm
Location: fi

Post by Maniac- »

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;
}
Should work on all resolutions.
Post Reply