faqts : Computers : Programming : Languages : PHP : Common Problems : Images

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

24 of 34 people (71%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

Can ImageCopyResized() be used with jpeg?

Mar 7th, 2001 11:33
Lol Morrisson, Claude Favre,


Yes, here is a function that uses it. It takes a handle to a JPEG, and 
size values, and returns the JPEG resized to the values specified.

Hope this helps.

Lol.




<?php

function resize_image ($image, $size_x, $size_y) {
    $srcimage         = ImageCreateFromJPEG ($image);
    $newimage        = imagecreate ($size_x, $size_y);
    imagecopyresized ($newimage, $srcimage, 0, 0, 0, 0, $size_x,
         $size_y, imagesx($srcimage), imagesy($srcimage));

    return $newimage;

}

?>