Page 1 of 1

[PHP] Shotcutter v. 0.01

Posted: Thu Aug 04, 2005 7:39 am
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:

Posted: Thu Aug 04, 2005 7:47 am
by MarlPoro
It's a shitty and useless code! iler is the suckage!

No really, you R the hax \,,\

Posted: Thu Aug 04, 2005 8:29 am
by Den
poika power!

Posted: Fri Aug 05, 2005 7:15 am
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;
	}  
}

Posted: Sat Aug 06, 2005 7:42 am
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. :)

Posted: Thu Aug 11, 2005 11:42 am
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.