PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Wed Aug 12, 2020 12:48 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: image resizing
PostPosted: Mon Sep 26, 2005 10:32 am 
Offline
Forum Commoner

Joined: Wed Jul 27, 2005 5:10 am
Posts: 44
Location: Paris,France.
i am well aware that this subject of resizing images or otherwise thumbnail generation has been dealt wid a zillion times in this forum..
i searched all the previous posts regarding this subject and still not found my answer..
im gonna post the code so dat someone will be able to tell me why i get a black block instead of the thumbnail format of the original image..
please note that ther is no database from where i call these images..they are just folders.

Syntax: [ Download ] [ Hide ]
$n_width="80"; // Fix the width of the thumb nail images

$n_height="80"; // Fix the height of the thumb nail imaage

$tsrc="thimg/$fname";

$msrc="upimg/$fname";





// Path where thumb nail image will be stored



if (!($ftype =="image/pjpeg" OR $ftype=="image/gif"))

{

if($ftype=="image/jpeg")

{

$im=@imagecreatefromjpeg($fname);

$width=imageSX($im);              // Original picture width is stored

$height=imageSY($im);             // Original picture height is stored

$newimage=imagecreatetruecolor($n_width,$n_height);                

imagecopyresampled($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);

imagejpeg($newimage,$tsrc);

imagecolorallocate($im,0,0,0);

chmod("$tsrc",0777);

chmod("$msrc",0777);


thank u


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 26, 2005 10:34 am 
Offline
Neighborhood Spidermoddy
User avatar

Joined: Mon Mar 29, 2004 4:24 pm
Posts: 31559
Location: Bothell, Washington, USA
your variables appear to come from thin air, how are they set?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 26, 2005 4:56 pm 
Offline
Briney Mod
User avatar

Joined: Mon Jan 19, 2004 7:11 pm
Posts: 6446
Location: 53.01N x 112.48W
When an image is created, it's black by default, then you put colours and images overtop of it. Tthis problem usually occurs because you're not copying the correct pixels. Echo all your width and height variables and see if any of them are zero, or not what you expect.

_________________
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group