Thanks Tedd and Dan. This code and the archives link helped me understand what I needed to do. I'm off and running and everything is working great. Much appreciated!!

-Aaron  

On Jan 31, 2007, at 12:24 PM, tedd wrote:

At 9:37 AM -0500 1/31/07, Aaron Fischer wrote:

I'm under severe time constraints to have a project completed so if someone has some GD resize stuff to help me get going I would be most appreciative. Tips/pointers are also helpful.


If you already know the picture name and type, this will work.

<?php
// The file
$filename = 'test.jpg';
$outfilename = "/path/picture.jpg";

// Set a maximum height and width
$width = 200;
$height = 200;

// Get new dimensions
list($width_orig, $height_orig) = getimagesize($filename);

if ($width && ($width_orig < $height_orig))
  {
   $width = ($height / $height_orig) * $width_orig;
  }
else
  {
   $height = ($width / $width_orig) * $height_orig;
  }

// Resample
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height,
$width_orig, $height_orig);

// Output
imagejpeg($image_p, $outfilename, 100);
?>


_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

Reply via email to