12:14:14 AM
Thursday
Sep 09
Su M Tu W Th F Sa
567891011
12131415161718
19202122232425
262728293012
3456789

Play My Typing Game

View Some of My Artwork

Using GD to resize a jpg
GD is pretty straight forward, with good documentation on the php/manual to learn how you can create/manipulate any image files using pure php code. Here's one way to make thumbnails (or resize, in general).

<?
function resizetowidth($filename, $new_width, $newfile='')
{
$filename = "some_picture.jpg";

$im = @ImageCreateFromJPEG($filename);

// get original's dimensions
list($img_width,$img_height) = getimagesize($filename);

$new_height = ceil(abs(($new_width/$img_width)*$img_height));

$canvas = @ImageCreateTrueColor($new_width, $new_height);
@ImageCopyResampled($canvas, $im, 0,0,0,0, $new_width, $new_height, $img_width, $img_height);

if($newfile!='')
{
 // write resized to file
 @ImageJPEG($canvas, $newfile); exit;
}
else
{
 //display in memory
 @ImageJPEG($canvas); exit;
}

}
?>


Read Previous:
Using Image Magick - Resize Image, Maintain Aspect Ratio
Read Next:
Using GD to replace colors
Table of Contents


Give a listen to my music...
My Best Recordings
How my services and skills can help you:
  • Global (via Email/Skype/AIM(ichat)/Yahoo)
    • Web Development Consulting
    • Custom Web App Development (PHP/MySQL/jQuery/CSS) Cross-Browser & OS
    • Cellphone App Development (Android/MobileWeb)
    • Music Lessons & Education for Beginner Guitar, Piano, Bass, which transfers over to many other instruments I am comfortable playing but not yet at teaching.
    • Music - Soundtrack Composition & Voice Work
  • Local
    • Most all the above, but also:
      • Music Performance (Harp, Voice, Guitar, Piano, Bass, Latin Percussion)
      • Recording Live Music Audio
      • Video Streaming live music and other live events anywhere that can provide wifi
      • Training Video Streaming to your venue's trusted soundperson
Skills:
  • Global (via Email/Skype/AIM(ichat)/Yahoo)
    • Web Development Consulting
    • Custom Web App Development (PHP/MySQL/jQuery/CSS) Cross-Browser & OS
    • Cellphone App Development (Android/MobileWeb)
    • Music Lessons & Education for Beginner Guitar, Piano, Bass, which transfers over to many other instruments I am comfortable playing but not yet at teaching.
    • Music - Soundtrack Composition & Voice Work
  • Local, Most all the above, but also:
    • Music Performance (Harp, Voice, Guitar, Piano, Bass, Latin Percussion)
    • Being your venue's soundman
    • Video Streaming live music and other live events anywhere that can provide wifi
    • Training Video Streaming to your venue's trusted soundperson