Jump to content

jond

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jond's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks MadTechie! I took what you said and fixed it a little to get the result I wanted. For anyone else interested this is the code. <?php // The file $filename = $_GET['src']; // Set a maximum height and width $width = 256; $height = 1000; // Content type header('Content-type: image/jpeg'); // Get new dimensions list($width_orig, $height_orig) = getimagesize($filename); $ratio_orig = $width_orig/$height_orig; if ($width/$height > $ratio_orig) { $width = $height*$ratio_orig; } else { $height = $width/$ratio_orig; } $height = 83; // Resample $image_p = imagecreatetruecolor($width, $height); $image = imagecreatefromjpeg($filename); $x=0; $y=0; $width=256; $height_orig = $height * $ratio_orig; imagecopyresampled($image_p, $image, 0, 0, $x, $y, $width, $height, $width_orig, $height_orig); imagejpeg($image_p); ?>
  2. Hi, I'm trying to resize and then crop an image. I found the following code for resizing an image. <?php // The file $filename = $_GET['src']; // Set a maximum height and width $width = 256; $height = 1000; // Content type header('Content-type: image/jpeg'); // Get new dimensions list($width_orig, $height_orig) = getimagesize($filename); $ratio_orig = $width_orig/$height_orig; if ($width/$height > $ratio_orig) { $width = $height*$ratio_orig; } else { $height = $width/$ratio_orig; } // Resample $image_p = imagecreatetruecolor($width, $height); $image = imagecreatefromjpeg($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); imagejpeg($image_p, null, 100); ?> I thought that I could put the result into a variable like $resized = imagejpeg($image_p, null, 100); to then use with this code for cropping the image. Replacing the $_GET with the $resized variable <?php $x=0; $y=0; $filename=$_GET['src']; header('Content-type:image/jpg'); header('Content-Disposition: attachment;filename='.$src); list($width, $height, $type, $attr) = getimagesize($filename); $w= $width ; $h= 86; $image=imagecreatefromjpeg($filename); $crop=imagecreatetruecolor($w,$h); imagecopy($crop,$image,0,0,$x,$y,$w,$h); imagejpeg($crop); ?> It seems though that I am wrong. Could someone help me with this? Thanks!
  3. Hi, I want to be able to sort a a list of images by clicking a button. I understand how to sort them with an sql query like this. $query = mysql_query("SELECT * FROM images ORDER BY date DESC LIMIT $offset, $rowsPerPage",$con); but how would I have two buttons so that the user could switch between descending and ascending? I've been trying submit buttons with if statements containing the sql query but I'm not having any luck. Thanks for any help
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.