All pastes #458424 Raw Edit

Ryan.

public php v1 · immutable
#458424 ·published 2007-04-25 21:43 UTC
rendered paste body
<?php# Load Image$img = open_image($_GET['img']);if ($img === false) { die ('Unable to open image'); }# Get Original Sizes$width = imagesx($image);$height = imagesy($image);# Set Sizeif($width > $height) {	$new_width = 128;	# Get Percentage	$percentage = ($new_width / $width) * 100;	# Calculate New Height	$new_height = $height / $percentage;} elseif($height > $width) {	$new_height = 128;	# Get Percentage	$percentage = ($new_height / $height) * 100;	# Calculate New Height	$new_width = $width / $percentage;} else {	$new_width = 128;	$new_height = 128;}# Create Image Base$new_img = imagecreatetruecolor($new_width, $new_height);# Resample The Imageimagecopyresampled($new_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height);# Set Header Typeheader('Content-type: image/jpeg');# Display Resized Imageimagejpeg($new_img);# End Scriptdie();?>