createimage in folder

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
molandim
Forum Newbie
Posts: 19
Joined: Thu Feb 20, 2003 11:33 am
Location: Brazil
Contact:

createimage in folder

Post by molandim »

Hi folks.

I have here one script that generate thumbnails.. but it did in the root folder, but i want that it take a original image in a folder called "img" and save the thumb file that it will create in folder called "thumbs" .. I am trying do that, but is not working

HELP PLEASE !!!

the code

Code: Select all

<?php

$imagem = "P1010060.jpg"; 

$thumbnail = explode('.', $imagem);
$thumbnail = $thumbnail&#1111;0]."_thumb.jpg";


$x = 150; 
$y = 150;


$img_origem = ImageCreateFromJPEG($imagem);


$origem_x = imagesx($img_origem); 
$origem_y = imagesy($img_origem); 
$scale = min($x/$origem_x , $y/$origem_y); 


if($scale < 1) &#123; 
$final_x = floor($scale*$origem_x);
$final_y = floor($scale*$origem_y); 
$f_x = 0; 
$f_y = 0; 
&#125;

$img_final = ImageCreatetruecolor($final_x,$final_y);


imagecopyresampled($img_final, $img_origem, $f_x, $f_y, 0, 0, $final_x, $final_y, $origem_x, $origem_y);


ImageJPEG($img_final, $thumbnail);


ImageDestroy($img_origem);
ImageDestroy($img_final);

?>
lostboy
Forum Contributor
Posts: 329
Joined: Mon Dec 30, 2002 8:12 pm
Location: toronto,canada

Post by lostboy »

in the image name, include the path to the new folder
Post Reply